2 Posts

May 31st, 2022 08:00

Found the issue. The following script does the trick:

 

$credential = Get-Credential # Enter like this: DOMAIN\Username
$password = $credential.GetNetworkCredential().password
$username = $credential.GetNetworkCredential().UserName
$domain = $credential.GetNetworkCredential().domain
$credPair = "$($domain)\$($username):$($password)"
$encodedCredentials = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($credPair))

$headers = @{
Authorization = "Basic $encodedCredentials";
"Accept" = "application/json";
"Content-Type" = "application/json"
}

Invoke-RestMethod -Method Get -Uri 'https://PluginServer.FQDN/api/v1/vms?fields=name,status' -Headers $headers

No Events found!

Top