Created
September 17, 2015 10:18
-
-
Save johnmmoss/592b1ff7bb02c5de951b to your computer and use it in GitHub Desktop.
Example helper method round using Invoke-RestMethod
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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