Skip to content

Instantly share code, notes, and snippets.

@johnmmoss
Created September 17, 2015 10:18
Show Gist options
  • Save johnmmoss/592b1ff7bb02c5de951b to your computer and use it in GitHub Desktop.
Save johnmmoss/592b1ff7bb02c5de951b to your computer and use it in GitHub Desktop.
Example helper method round using Invoke-RestMethod
# Read out proxy settings
$Webproxy = (get-itemproperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings').ProxyServer
# Wrapper method for Invokeing a rest method
function Invoke-Request {
Param( [string]$Method="GET", [string]$Body, [string]$Url )
if($Method -eq "GET") {
return Invoke-RestMethod -Proxy $Webproxy -UseDefaultCredentials -URI $Url -Method "GET"
} else {
return Invoke-RestMethod -Proxy $Webproxy -UseDefaultCredentials -URI $Url -ContentType "application/json" -Method $Method -Body $Body
}
}
#Example Usage Get
Invoke-Rest -Url "https://octopus2/api//Teams?apiKey=$API_KEY"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment