Created
May 18, 2026 14:13
-
-
Save shinusuresh/a2c3e252478fdd588085c1da5b8081af to your computer and use it in GitHub Desktop.
Cyberark powershell
This file contains hidden or 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
| $cyberArkHost = "<PVWA ADDRESS>" | |
| $logonUrl = "https://$cyberArkHost/PasswordVault/API/auth/Cyberark/Logon" | |
| $accountsUrl = "https://$cyberArkHost/PasswordVault/api/Accounts" | |
| $username = Read-Host 'Username' | |
| $pass = Read-Host 'Password' -AsSecureString | |
| $bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($pass) | |
| $password = [Runtime.InteropServices.Marshal]::PtrToStringAuto($bstr) | |
| [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | |
| $logonBody = @{ | |
| Username = $username | |
| Password = $password | |
| } | |
| $token = Invoke-RestMethod -Uri $logonUrl -Method Post -ContentType 'application/x-www-form-urlencoded' -Body $logonBody | |
| $headers = @{ | |
| Authorization = $token | |
| Accept = 'application/json' | |
| } | |
| $response = Invoke-RestMethod -Uri $accountsUrl -Method Get -Headers $headers | |
| $accounts = $response.value | Select-Object ` | |
| id, | |
| name, | |
| userName, | |
| address, | |
| platformId, | |
| safeName, | |
| secretType, | |
| createdTime | |
| $accounts | Export-Csv -Path ".CyberArkAccounts.csv" -NoTypeInformation | |
| $accounts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment