The response content cannot be parsed because the Internet Explorer engine is not available, or
I need to download a channel 9 series using powershell, however the scripts I have tried have errors:
-
This script
$url="https://channel9.msdn.com/blogs/OfficeDevPnP/feed/mp4high" $rss=invoke-webrequest -uri $url $destination="D:\Videos\OfficePnP" [xml]$rss.Content|foreach{ $_.SelectNodes("rss/channel/item/enclosure") }|foreach{ "Checking $($_.url.split("/")[-1]), we will skip it if it already exists in $($destination)" if(!(test-path ($destination + $_.url.split("/")[-1]))){ "Downloading: " + $_.url start-bitstransfer $_.url $destination } }
failed with error:
The response content cannot be parsed because the Internet Explorer engine is not available, or Internet Explorer's first-launch configuration is not complete. Specify the UseBasicParsing parameter and try again.
-
I also tried this one
# --- settings --- $feedUrl = "https://channel9.msdn.com/blogs/OfficeDevPnP/feed/mp4high" $mediaType = "mp4high" $overwrite = $false $destinationDirectory = join-path ([Environment]::GetFolderPath("MyDocuments")) "OfficeDevPnP" # --- locals --- $webClient = New-Object System.Net.WebClient # --- functions --- function PromptForInput ($prompt, $default) { $selection = read-host "$prompt`r`n(default: $default)" if ($selection) {$selection} else {$default} } function DownloadEntries { param ([string]$feedUrl) $feed = [xml]$webClient.DownloadString($feedUrl) $progress = 0 $pagepercent = 0 $entries = $feed.rss.channel.item.Length $invalidChars = [System.IO.Path]::GetInvalidFileNameChars() $feed.rss.channel.item | foreach { $url = New-Object System.Uri($_.enclosure.url) $name = $_.title $extension = [System.IO.Path]::GetExtension($url.Segments[-1]) $fileName = $name + $extension $invalidchars | foreach { $filename = $filename.Replace($_, ' ') } $saveFileName = join-path $destinationDirectory $fileName $tempFilename = $saveFilename + ".tmp" $filename if ((-not $overwrite) -and (Test-Path -path $saveFileName)) { write-progress -activity "$fileName already downloaded" -status "$pagepercent% ($progress / $entries) complete" -percentcomplete $pagepercent } else { write-progress -activity "Downloading $fileName" -status "$pagepercent% ($progress / $entries) complete" -percentcomplete $pagepercent $webClient.DownloadFile($url, $tempFilename) rename-item $tempFilename $saveFileName } $pagepercent = [Math]::floor((++$progress)/$entries*100) } } # --- do the actual work --- [string]$feedUrl = PromptForInput "Enter feed URL" $feedUrl [string]$mediaType = PromptForInput "Enter media type`r`n(options:Wmv,WmvHigh,mp4,mp4high,zune,mp3)" $mediaType $feedUrl += $mediaType [string]$destinationDirectory = PromptForInput "Enter destination directory" $destinationDirectory # if dest dir doesn't exist, create it if (!(Test-Path -path $destinationDirectory)) { New-Item $destinationDirectory -type directory } DownloadEntries $feedUrl
with too many errors
http://screencast.com/t/bgGd0s98Uc
Solution 1:
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 parameter is required when Internet Explorer is not installed on the computers, such as on a Server Core installation of a Windows Server operating system.
Solution 2:
To make it work without modifying your scripts:
I found a solution here: http://wahlnetwork.com/2015/11/17/solving-the-first-launch-configuration-error-with-powershells-invoke-webrequest-cmdlet/
The error is probably coming up because IE has not yet been launched for the first time, bringing up the window below. Launch it and get through that screen, and then the error message will not come up any more. No need to modify any scripts.
Solution 3:
You can disable need to run Internet Explorer's first launch configuration by running this PowerShell script, it will adjust corresponding registry property:
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Internet Explorer\Main" -Name "DisableFirstRunCustomize" -Value 2
After this, WebClient will work without problems
Solution 4:
It is sure because the Invoke-WebRequest command has a dependency on the Internet Explorer assemblies and are invoking it to parse the result as per default behaviour. As Matt suggest, you can simply launch IE and make your selection in the settings prompt which is popping up at first launch. And the error you experience will disappear.
But this is only possible if you run your powershell scripts as the same windows user as whom you launched the IE with. The IE settings are stored under your current windows profile. So if you, like me run your task in a scheduler on a server as the SYSTEM user, this will not work.
So here you will have to change your scripts and add the -UseBasicParsing argument, as ijn this example: $WebResponse = Invoke-WebRequest -Uri $url -TimeoutSec 1800 -ErrorAction:Stop -Method:Post -Headers $headers -UseBasicParsing