The response content cannot be parsed because the Internet Explorer engine is not available, or

In your invoke web request just use the parameter -UseBasicParsing e.g. in your script (line 2) you should use: $rss = Invoke-WebRequest -Uri $url -UseBasicParsing According to the documentation, this parameter is necessary on systems where IE isn’t installed or configured: Uses the response object for HTML content without Document Object Model (DOM) parsing. This … Read more

Boolean literals in PowerShell

$true and $false. Those are constants, though. There are no language-level literals for Booleans. Depending on where you need them, you can also use anything that coerces to a Boolean value, if the type has to be Boolean, e.g., in method calls that require Boolean (and have no conflicting overload), or conditional statements. Most non-null … Read more

How do you run a SQL Server query from PowerShell?

For others who need to do this with just stock .NET and PowerShell (no additional SQL tools installed) here is the function that I use: function Invoke-SQL { param( [string] $dataSource = “.\SQLEXPRESS”, [string] $database = “MasterData”, [string] $sqlCommand = $(throw “Please specify a query.”) ) $connectionString = “Data Source=$dataSource; ” + “Integrated Security=SSPI; ” … Read more

PowerShell: How do I convert an array object to a string in PowerShell?

$a=”This”, ‘Is’, ‘a’, ‘cat’ Using double quotes (and optionally use the separator $ofs) # This Is a cat “$a” # This-Is-a-cat $ofs=”-” # after this all casts work this way until $ofs changes! “$a” Using operator join # This-Is-a-cat $a -join ‘-‘ # ThisIsacat -join $a Using conversion to [string] # This Is a cat … Read more

Call PowerShell script PS1 from another PS1 script inside Powershell ISE

In order to find the location of a script, use Split-Path $MyInvocation.MyCommand.Path (make sure you use this in the script context). The reason you should use that and not anything else can be illustrated with this example script. ## ScriptTest.ps1 Write-Host “InvocationName:” $MyInvocation.InvocationName Write-Host “Path:” $MyInvocation.MyCommand.Path Here are some results. PS C:\Users\JasonAr> .\ScriptTest.ps1 InvocationName: .\ScriptTest.ps1 … Read more