- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
Our community just got stronger! Explore new identity security resources, connect with experts, and discover more ways to learn and collaborate.
12-24-2025 04:25 AM
Hi, is the below the correct syntax using the RESTAPI DiscoveredAccounts GET method?
logonHeader = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$logonHeader.Add("Authorization", $token)
$AllDiscAccounts = @()
$URI = 'https://PVWA/PasswordVault/API/DiscoveredAccounts? filter=platformType eq Unix'
$DiscoveredAccounts = Invoke-RestMethod -Method Get -Uri $URI -Headers $logonHeader -ContentType "application/json"
$Limit = 1000
$Offset = 0
Reason I ask is the result set being returned doesnt return the Unix entries but Window Local Server entries(not what filter above is asking for as expecting it to return Unix entries) which seems wrong, hence me checking the syntax as defined ion the online docs is correct?
Thanks for any replies.
01-02-2026 03:27 AM
Ok, so now have a solution:
Changed:
$URI2 = $URI+"?limit=$Limit&offset=$Offset&?filter=platformType eq Unix"
To
$URI2 = $URI+"?filter=platformType eq Unix&limit=$Limit&offset=$Offset"
So a change in order and result set is now correct in script.
Also a move in filter away from where initially was:
$URI = 'https://PVWA/PasswordVault/API/DiscoveredAccounts? filter=platformType eq Unix'
Now have
$URI = 'https://PVWA/PasswordVault/API/DiscoveredAccounts'
These changes have resulted in the result set we were expecting from the script.
12-24-2025 09:34 AM
Hey @Stephen Clarke Are you expecting the space: "? filter" Additionally, how were these accounts discovered?
Please note, discovered accounts that were onboarded either manually or automatically, according to predefined rules, won't be returned using this method:
https://docs.cyberark.com/pam-self-hosted/latest/en/content/webservices/get-discovered-accounts.htm
12-29-2025 05:11 AM
Hi @Stephen Clarke
It appears that @pbx has shared an answer to your question. Could you let us know if that solved the issue?
If it did, please mark the answer as “Select as Best” so it can help other community members too.
Thank you,
Shaked
01-02-2026 01:10 AM
Hi,
we have no rules in place as we are in "discovery mode", the code is exactly as in the online documentation?
we just changes platform aspect in attempt to prove filter actually works and returns only row we have asked for that applicable to filter? So in out example only the rows where platformType eq Unix.
we tried without the space and other filters such as Windows Domain, same result data set not looking like its being filtered correctly.
we are filtering as have hit the hardcoded 20k row limit.
Thanks
01-02-2026 01:43 AM
Hi @Stephen Clarke
Please try removing space and ensure the filter value is in single quotes
$URI = "https://PVWA/PasswordVault/API/DiscoveredAccounts?filter=platformType eq 'Unix'"
Ensure there is no space between ? and filter
Please try this formatting
.../DiscoveredAccounts?filter=platformType%20eq%20'Unix'
Hope it helps !
01-02-2026 02:42 AM
Hi, so we have tried a few of the suggestions but are still at the point where the data set returned seems not to equate to the data returned from the script in that filter seems to be ignored.
Have attached the entire code snippett.
# Ignore certs
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }
# Set TLS
[Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'TLS12,TLS13'
$token = Invoke-RestMethod -Uri 'https://PVWA/PasswordVault/API/Auth/CyberArk/Logon' `
-Method POST `
-Headers @{ 'Content-Type' = 'application/json' } `
-Body '{ "username": "*********", "password": "*********" }'
$logonHeader = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$logonHeader.Add("Authorization", $token)
$URI = 'https://PVWA/PasswordVault/API/Platforms'
$platforms = Invoke-RestMethod -Method Get -Uri $URI -Headers $logonHeader -ContentType "application/json"
##############################################
[Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'TLS12,TLS13'
$token = Invoke-RestMethod -Uri 'https://PVWA/PasswordVault/API/Auth/CyberArk/Logon' `
-Method POST `
-Headers @{ 'Content-Type' = 'application/json' } `
-Body '{ "username": "********", "password": "********" }'
$logonHeader = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$logonHeader.Add("Authorization", $token)
$URI = 'https://PVWA/PasswordVault/API/DiscoveredAccounts'
$DiscoveredAccounts = Invoke-RestMethod -Method Get -Uri $URI -Headers $logonHeader -ContentType "application/json"
###############################################
[Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'TLS12,TLS13'
$token = Invoke-RestMethod -Uri 'https://PVWA/PasswordVault/API/Auth/CyberArk/Logon' `
-Method POST `
-Headers @{ 'Content-Type' = 'application/json' } `
-Body '{ "username": *******", "password": "*******" }'
$logonHeader = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$logonHeader.Add("Authorization", $token)
$AllDiscAccounts = @()
$URI = 'https://PVWA/PasswordVault/API/DiscoveredAccounts'
$DiscoveredAccounts = Invoke-RestMethod -Method Get -Uri $URI -Headers $logonHeader -ContentType "application/json"
$Limit = 1000
$Offset = 0
Do {
$URI2 = $URI+"?limit=$Limit&offset=$Offset&?filter=platformType eq Unix"
write-host "Calling"$URI2
$Next = Invoke-RestMethod -Method Get -Uri $URI2 -Headers $logonHeader -ContentType "application/json"
$AllDiscAccounts += $Next.value
$Offset +=$Limit
}
While
(
$Next.value.count -eq $Limit
)
$AllDiscAccounts | export-csv 'c:\temp\DiscoveredAccs1.csv'
To be clear the result set from script above doesnt contain "only" Unix platform entries from discovered accounts.
So on paper looks like the filter is being ignored and trying to understand why?
Thanks for any assistance.
01-02-2026 03:27 AM
Ok, so now have a solution:
Changed:
$URI2 = $URI+"?limit=$Limit&offset=$Offset&?filter=platformType eq Unix"
To
$URI2 = $URI+"?filter=platformType eq Unix&limit=$Limit&offset=$Offset"
So a change in order and result set is now correct in script.
Also a move in filter away from where initially was:
$URI = 'https://PVWA/PasswordVault/API/DiscoveredAccounts? filter=platformType eq Unix'
Now have
$URI = 'https://PVWA/PasswordVault/API/DiscoveredAccounts'
These changes have resulted in the result set we were expecting from the script.
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!

