Skip to content

Instantly share code, notes, and snippets.

@m0veax
Last active May 27, 2024 12:18
Show Gist options
  • Save m0veax/af094c436b228da72070ebd1c370003b to your computer and use it in GitHub Desktop.
Save m0veax/af094c436b228da72070ebd1c370003b to your computer and use it in GitHub Desktop.
Powershell to test a connection
# create json object
$params = @{ `
'element' = 'value' `
}
Write-Output "defined parameters"
# start dialog to get authentification data
$cred = Get-Credential
# delete Method, ContentType and Body to do a GET Request
# delete Credential to avoid basic authentication
$Response = Invoke-WebRequest `
-Uri https://example.com/endpoint `
-Method POST `
-Body ($params|ConvertTo-Json) `
-ContentType "application/json" `
-Credential $cred `
-Verbose
Write-Output "started request"
$Response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment