invoke-webrequest

Invoke-Webrequest gets 401 on POST but not on GET with Basic Auth

﹥>﹥吖頭↗ 提交于 2021-02-08 07:35:48
问题 I have a dev site with Basic Auth enabled. I am get to GET a page using the following to add basic auth to the headers: $creds = "$($BASIC_AUTH_USER):$($BASIC_AUTH_PASS)" $encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($creds)) $basicAuthValue = "Basic $encodedCreds" $headers = @{ Authorization = $basicAuthValue } $login = Invoke-WebRequest $url -SessionVariable session -UseBasicParsing -Headers $headers But I am unable to post to the same URL: $fields

Stubborn Ampersand with Invoke-Webrequest SQL & Powershell

北城以北 提交于 2021-01-28 11:43:22
问题 When I run powershell using invoke-webrequest on a URL without an ampersand everything works. But my URL's have ampersands in them. If I surround them by double quotes it works from PowerShell, but not if I am doing it through my SQL Server. Trying to get the right combination of escape characters is proving to be a pain in the butt. Here's an example of the command: exec xp_cmdshell 'powershell Invoke-WebRequest -UseBasicParsing -Uri "https://example.com/getfile/12345&i=123" -outfile C:

Powershell ConvertFrom-Json Encoding Special Characters Issue

血红的双手。 提交于 2021-01-01 04:23:12
问题 I have this code in my powershell script and it doesn't do well on the special characters parts. $request = 'http://151.80.109.18:8082/vrageremote/v1/session/players' $a = Invoke-WebRequest -ContentType "application/json; charset=utf-8" $request | ConvertFrom-Json | Select -expand Data | Select -expand players | Select displayName, factionTag | Out-file "$scriptPath\getFactionTag.txt" In my output file I only get '????' for any special characters. Does anyone know how I can get it to show

Powershell ConvertFrom-Json Encoding Special Characters Issue

冷暖自知 提交于 2021-01-01 04:20:09
问题 I have this code in my powershell script and it doesn't do well on the special characters parts. $request = 'http://151.80.109.18:8082/vrageremote/v1/session/players' $a = Invoke-WebRequest -ContentType "application/json; charset=utf-8" $request | ConvertFrom-Json | Select -expand Data | Select -expand players | Select displayName, factionTag | Out-file "$scriptPath\getFactionTag.txt" In my output file I only get '????' for any special characters. Does anyone know how I can get it to show

Rewrite CURL in PowerShell using Invoke-WebRequest with multiple certificates

和自甴很熟 提交于 2020-12-12 10:22:07
问题 I use the following curl command to publish some data from an IoT Thing to AWS's IoT Core service. curl.exe --tlsv1.2 --cacert root-CA.pem --cert certificate.pem --key private.pem -X POST -d "$($Body)" "https://ats.iot.eu-west-1.amazonaws.com:8443/topics/example/1" The command works perfectly, but I would like to leverage the features of the Invoke-WebRequest commandlet. Unfortunately I cannot figure out how to rewrite the curl command, primarily because of the two certificates and key file.

REST API failure: Invoke-WebRequest : 404

半腔热情 提交于 2020-04-15 17:18:17
问题 The Powershell code bellow writes and reads values to Google Sheets (works fine) and should run the function myfunction in an Apps Script project using API, but Invoke-WebRequest returns the error bellow: Invoke-WebRequest : 404. That’s an error. The requested URL /v1/scripts/=ya29.a0Ae4lvC3k8aahOCPBgf-tRf4SRFxdcCE97fkbXLAJqZ4zRCLnBp9prwEcBYBAf lYP6zyW3fLeD3u4iSw5jYtDAdgZiSsTjzQbCpj9e_ahCA0xwC_1NBTjYkPwqFdLli7LNpfFcuedFDhdUpfnKTRZdbBWIf2ZyxyuGc6p was not found on this server. That’s all we

REST API failure: Invoke-WebRequest : 404

我只是一个虾纸丫 提交于 2020-04-15 17:13:23
问题 The Powershell code bellow writes and reads values to Google Sheets (works fine) and should run the function myfunction in an Apps Script project using API, but Invoke-WebRequest returns the error bellow: Invoke-WebRequest : 404. That’s an error. The requested URL /v1/scripts/=ya29.a0Ae4lvC3k8aahOCPBgf-tRf4SRFxdcCE97fkbXLAJqZ4zRCLnBp9prwEcBYBAf lYP6zyW3fLeD3u4iSw5jYtDAdgZiSsTjzQbCpj9e_ahCA0xwC_1NBTjYkPwqFdLli7LNpfFcuedFDhdUpfnKTRZdbBWIf2ZyxyuGc6p was not found on this server. That’s all we

How to check status of list of Websites / URLs? (Using Power-Shell script)

帅比萌擦擦* 提交于 2020-03-05 06:05:19
问题 I want to take the http status of multiple URL at once to prepare a report. How to acheive it using powershell? 回答1: I have seen questions on monitoring multiple websites through windows machine. My friend wanted to check status of 200 URLs which he used to do manually. I wrote a Power-Shell script to overcome this. Posting it for the benefit of all users. Save the below code as "AnyName.ps1" file in "D:\MonitorWeb\" #Place URL list file in the below path $URLListFile = "D:\MonitorWeb\URLList

Whats the replacement for WebResponse.AllElements in PowerShell Core 6?

巧了我就是萌 提交于 2020-01-25 05:22:24
问题 I have to parse a html file (find div with class xyz and use the inner text). That would be quit simple by using and filtering the WebResponse.AllElements collection. This member seems to be not available in PowerShell Core 6 (on a Mac). On this platform, I get an BasicHtmlWebResponseObject as the return value of the Invoke-WebRequest $Url call which lags tis property. I don't want to use any C# code or external libraries. What would be an maintainable way to get the same functionality as on