Skip to content

Instantly share code, notes, and snippets.

@infamousjoeg
Last active January 24, 2024 17:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save infamousjoeg/8dd99f40b9a52043655363e2c9811d52 to your computer and use it in GitHub Desktop.
Save infamousjoeg/8dd99f40b9a52043655363e2c9811d52 to your computer and use it in GitHub Desktop.
CCP GetPassword in PowerShell with Client Certificate
# 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