Skip to content

Instantly share code, notes, and snippets.

@ryanvgates
Created April 13, 2022 20:57
Show Gist options
  • Save ryanvgates/7627a2e608b547ecdd7c2c5516886978 to your computer and use it in GitHub Desktop.
Save ryanvgates/7627a2e608b547ecdd7c2c5516886978 to your computer and use it in GitHub Desktop.
CyberArk PowerShell Login
Add-Type -AssemblyName System.Web
$cred = Get-Credential -Message "Please enter the credentials for logging into CyberArk host cyberarkhost.com" -UserName $env:UserName
$AUTH_URI = "https://cyberarkhost.com/PasswordVault/API/auth/LDAP/Logon"
$Headers = @{'accept'='application/json';'content-type'='application/json'}
$body=@{
username = "$($cred.UserName)"
password= "$($cred.GetNetworkCredential().password)"
}
$CyberBody = $body | convertto-json
$token = Invoke-RestMethod -Method Post -Uri $AUTH_URI -Body $CyberBody -Headers $Headers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment