Skip to content

Instantly share code, notes, and snippets.

@infamousjoeg
Created April 24, 2023 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save infamousjoeg/d1b2b746f09eae3125e97430726cb9d1 to your computer and use it in GitHub Desktop.
Save infamousjoeg/d1b2b746f09eae3125e97430726cb9d1 to your computer and use it in GitHub Desktop.
Get Credential Provider Details from System Health via PVWA REST API
# Get User Input
$pvwaURL = $(Read-Host "PVWA Base URL (eg. https://pvwa.example.com)").TrimEnd("/")
do {
$authType = Read-Host "Authentication Type [cyberark], ldap, radius"
if ($authType -eq "") { $authType = "cyberark" }
else { $authType = $authType.ToLower() }
} until ($authType -eq "cyberark" -or $authType -eq "ldap" -or $authType -eq "radius")
$credentials = Get-Credential
# Logon to PVWA REST API
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$body = @"
{
`"username`": `"$($credentials.UserName)`",
`"password`": `"$($credentials.GetNetworkCredential().Password)`",
`"concurrentSession`": `"true`"
}
"@
$logonURL = "${pvwaURL}/passwordvault/api/auth/${authType}/logon"
$response = Invoke-RestMethod $logonURL -Method POST -Headers $headers -Body $body
$token = $response.Trim("`"")
# Get Details of Credential Providers
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", $token)
$headers.Add("Content-Type", "application/json")
$detailsURL = "${pvwaURL}/passwordvault/api/componentsmonitoringdetails/aim"
$response = Invoke-RestMethod $detailsURL -Method GET -Headers $headers
$response | ConvertTo-Json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment