Last active
November 19, 2024 18:33
-
-
Save infamousjoeg/8dd99f40b9a52043655363e2c9811d52 to your computer and use it in GitHub Desktop.
CCP GetPassword in PowerShell with Client Certificate
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
# Set request variables | |
$baseURL = "https://cyberark.joegarcia.dev" | |
$appID = "Ansible" | |
$safe = "D-Win-SvcAccts" | |
$object = "Operating System-WinDomain-joegarcia.dev-Svc_SSIS" | |
# Define the certificate thumbprint | |
$thumbprint = "INSERT_CERTIFICATE_THUMBPRINT_HERE" | |
# Retrieve the certificate from Current User's Personal certificate store | |
$certificate = Get-ChildItem -Path Cert:\CurrentUser\My\ | Where-Object { $_.Thumbprint -eq $thumbprint } | |
if ($certificate -eq ''){ | |
throw "No Certificate found"; | |
} | |
# Define the URI for the REST call | |
$uri = "${baseURL}/AIMWebService/api/Accounts?AppID=${appID}&Safe=${safe}&Object=${object}" | |
# Make the REST call using the certificate | |
$response = Invoke-RestMethod -Uri $uri -Method Get -Certificate $certificate | |
# Output the response | |
$response | |
$response.content |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment