Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Invoke-WebRequest causes "Look for an app in the Store"

$
0
0

I am making a bunch of Invoke-WebRequests, to convert a fair few HTML files into a single document.

There's obviously some transformations that occur before this can be achieved, however I am repeatedly getting the popup, "You'll need a new app to open this about

Look for an app in the Store"

The code isn't earth shattering good, cause it is just a quick and dirty but this dialog appears despite the various attempts to make it not do so.

$sourcePages = [PSObject[]]@(
  @{"name"="First Page"; "url"="http://localhost/1.htm"},
  @{"name"="Second Page"; "url"="http://localhost/2.htm"},
  # etc
);

for ($i = 0; $i -lt $sourcePages.Count; $i++) {
 $pageItem = $sourcePages[$i];
 $pageUrl = $pageItem.url;
 $req = Invoke-WebRequest $pageUrl;

 # Note: have tried ([void]($req = Invoke-WebRequest $url)) to avoid the popups, but they still occur
 # The annoying "you'll need a new app to open this about" appears straight after the Invoke-WebRequest call.

 $outFile = $i.ToString().PadLeft(5, '0') + ' - ' + $pageItem.name + '.htm';

 $body = $req.ParsedHtml.body;
 # remove the parts we don't need
 $body.childNodes | ? { $_.nodeType -eq 3 -or $_.type -eq 'hidden' -or $_.className -ilike '*aboveheading*' -or $_.className -ilike '*relatedTopics*' -or $_.tagName -eq 'SCRIPT' } | % { $body.removeChild($_); };
 # get rid of a javascript function call in the onload attribute
 $body.attributes.getNamedItem('onload').textContent = '';

 [system.io.file]::WriteAllText($pwd.Path + '\' + $outfile, $body.outerHTML);
}

This is on a fresh install of Windows 10 by the way, and the only thing installed is Office 2016 and Visual Studio 15 Preview 5.

The annoying "You'll need a new app" dialog pops up, but whilst it doesn't freeze the script it doesn't let other apps recognise input until you click out of the dialog till it goes away or you hit escape on the dialog.

No, looking for an app in the store returned no results, and I'm wondering if it's somehow getting referred to an "about:blank" or similar page causing this issue, since it says I need a new app to open thisabout


Viewing all articles
Browse latest Browse all 15028

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>