invoke-restmethod

How do I POST from Powershell using Invoke-RestMethod

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-10 16:56:13
问题 As per https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-7#example-2--run-a-post-request I am trying to invoke a simple POST method but getting some errors. My instruction is: $uri = "https://localhost:44355/api/job/machine-status"; #$machineName = HOSTNAME.EXE; $machineName = "simPass2"; $body = @{ Name = $machineName Status = "Complete" } Invoke-RestMethod -Method 'Post' -Uri $uri -ContentType 'application/json' -Body $body;

How to convert a response from Invoke-RestMethod to XML?

风流意气都作罢 提交于 2021-01-28 11:15:24
问题 Referencing the help file for `Invoke-RestMethod: PS /home/nicholas> PS /home/nicholas> $response = Invoke-RestMethod -Uri https://blogs.msdn.microsoft.com/powershell/feed/ PS /home/nicholas> PS /home/nicholas> $json = $response | ConvertTo-Json WARNING: Resulting JSON is truncated as serialization has exceeded the set depth of 2. PS /home/nicholas> PS /home/nicholas> $xml = $response | ConvertTo-Xml PS /home/nicholas> PS /home/nicholas> $xml.OuterXml How can I convert the response to xml and

How to pipe downloaded CSV data from Invoke-RestMethod to Import-CSV?

懵懂的女人 提交于 2020-12-15 04:54:51
问题 How can I represent, or at least view, this data? PS /home/nicholas> PS /home/nicholas> $labs='http://www.bccdc.ca/Health-Info-Site/Documents/BCCDC_COVID19_Dashboard_Lab_Information.csv' PS /home/nicholas> PS /home/nicholas> $labs_csv=Invoke-RestMethod -Method Get -Uri $labs -Headers @{"Content-Type" = "text/csv"} PS /home/nicholas> PS /home/nicholas> $labs_csv "Date","Region","New_Tests","Total_Tests","Positivity","Turn_Around" 2020-01-23,"BC",2,2,0,32 2020-01-23,"Fraser",0,0,0,0 2020-01-23,