- 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-06-2019 02:38 AM
PS D:\scripts> D:\scripts\test-CCPCredential.ps1
[ERROR] Failed to fetch password for user TestUser : System.Net.WebException: The remote server returned an error: (401) Unauthorized. at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
From IIS logs :
2019-12-06 10:36:04 fe80::e0b0:31eb:c4a8:661f%3 GET /AIMWebService/api/Accounts Safe=APP_CSK_TDA_CYBERARK_AUTOMAT&AppID=APP_CSK_ACC_CYBERARK_AUTOMATION&UserName=TestUser 443 - fe80::e0b0:31eb:c4a8:661f%3 Mozilla/5.0+(Windows+NT;+Windows+NT+10.0;+en-US)+WindowsPowerShell/5.1.14393.3053 - 401 2 5 125
12-06-2019 04:42 AM
have you tried using -UseDefaultCredentials switch?
12-06-2019 04:42 AM
have you tried using -UseDefaultCredentials switch?
12-06-2019 05:26 AM
Indeed, that was the solution! So simple. Thank you very much !!!
06-15-2020 03:40 AM
Hi @wdams, when I used the get-ccpcredential, it retrieved all the accounts properties, how did you get only the password out and where did you use the -UseDefaultCredentials switch?
06-15-2020 04:00 AM
This is how you should use it. If you only need the password than only get the content attribute.
$CyberArkRecord = Get-CCPCredential -URL $CCP_URL -Safe "YOUR_SAFE" -AppID "YOUR_APP" -UserName "USER_TO_FIND" -UseDefaultCredentials -ErrorAction Stop
$CyberArkRecord.Content
06-18-2020 01:28 AM
@Wim Dams
Thanks for the tip.
Im trying to insert the content into a variable so that I can use it.
I'm trying to use ConvertTo-SecureString, but when I try to use it, it fails on the network, probably due to special characters.
Any suggestions?
06-18-2020 01:38 AM
I also use the ConverTo-Securestring function to convert the Password into a Powershell Credential object.
See example.
$PWord = ConvertTo-SecureString -String $CyberArkRecord.Content -AsPlainText -Force
$Cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $ConnectUser, $PWord
Never had issues with this.
06-18-2020 02:18 AM
check out the "ToSecureString" & "ToCredential" methods included with the module....
https://github.com/pspete/CredentialRetriever#tosecurestring-method
$result = Get-CCPCredential -AppID PS -Safe PS -Object PSP-AccountName -URL https://cyberark.yourcompany.com
$result.ToSecureSting()
$result.ToCredential()
06-18-2020 03:20 AM
Still doesn't work for me.
I've executed:
$CyberArkRecord = Get-CCPCredential -URL https://URL -Safe <safe name> -AppID baruch -object 'object name' -UseDefaultCredentials -ErrorAction Stop
then,
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList @($user, $CyberArkRecord.ToSecureString())
and finally,
start explorer.exe \\server name\c$ -Credential $cred
but it keeps prompting for user and password, and the creds in the vault are correct
06-18-2020 04:27 AM
Have seen something similar if "Hostname\" or "Domain\" is not specified before the username.
06-18-2020 04:36 AM
but I do specify domain\username
06-20-2020 11:28 PM
@Pete Maan
can I show you what I am trying to do to?
Perhaps a quick session?
06-29-2020 03:15 AM
Hi,
Does anyone have a script to rotate many password account ?
Thank you
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!

