This topic contains 3 replies, has 2 voices, and was last updated by
January 26, 2016 at 11:05 am #34324
Using PowerShell Studio... I've created a form that pulls warranty info from Dell's website. The click event runs the following...
$apikey = "(redacted)" $serial = $textboxSerialNumber.Text [xml]$XML = (Invoke-WebRequest -Uri "https://api.dell.com/support/v2/assetinfo/warranty/tags.xml?apikey=$apikey&svctags=$serial") $datetimepickerPurchaseDate.Text = Get-Date $XML.GetAssetWarrantyResponse.GetAssetWarrantyResult.Response.DellAsset.ShipDate -Format d
If I run it as a PSF from PowerShell studio if returns the date. If I build it and run it as an EXE I get the following error.
Invoke-WebRequest : Unable to connect to the remote server
At line:292 char:18
+ ... xml]$XML = (Invoke-WebRequest -Uri "https://api.dell.com/support/v2/a ...
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:Htt
pWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShe
January 26, 2016 at 11:09 am #34326KeymasterTopics: 13Replies: 4872Points: 1,811Rank: Community Hero
It could be a Windows Firewall setting. Once you're running an EXE, you appear to the firewall as a distinct process, so it might be blocking outbound access. But you'd have to ask SAPIEN if there might be any other differences between running as a packaged EXE.
Aaaaand I'm gonna edit out your API key.
January 26, 2016 at 11:20 am #34327
Thanks Don. That was the first thing I thought of. No bueno. 🙁
My bad on the key. That's one Dell makes publicly available for use with their api so I didn't think about it. 🙂
January 27, 2016 at 11:03 am #34385
If it's not the firewall, it's antivirus... facepalm.
The topic ‘Invoke-WebRequest in PowerShell form’ is closed to new replies.