Last active
September 23, 2017 02:21
-
-
Save infamousjoeg/b2730422d55a14d1ee9297d62bfd7203 to your computer and use it in GitHub Desktop.
This file contains 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
function Get-AIMPassword ([string]$PVWA_URL, [string]$AppID, [string]$Safe, [string]$ObjectName) { | |
# Declaration | |
$fetchAIMPassword = "${PVWA_URL}/AIMWebService/api/Accounts?AppID=${AppID}&Safe=${Safe}&Folder=Root&Object=${ObjectName}" | |
# Execution | |
try { | |
$response = Invoke-RestMethod -Uri $fetchAIMPassword -Method GET -ContentType "application/json" -ErrorVariable aimResultErr | |
Return $response.content | |
} | |
catch { | |
Write-Host "StatusCode: " $_.Exception.Response.StatusCode.value__ | |
Write-Host "StatusDescription: " $_.Exception.Response.StatusDescription | |
Write-Host "Response: " $_.Exception.Message | |
Return $false | |
} | |
} | |
$password = Get-AIMPassword -PVWA_URL "https://pvwa.cyberark.local" -AppID "ApplicationID" -Safe "SafeName" -ObjectName "ObjectName" | |
Write-Host "Your password is: ${password}" |
Author
infamousjoeg
commented
Sep 22, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment