- 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.
04-28-2022 10:10 AM
I can successfully grab the password, but keep getting an invalid username/password when trying to use it in PSCredential. I can copy and paste the password from the script and login via RDP. so i know the password is correct.
#Variables
$CCPHost = "aimservice.com"
$appID = "app"
$safe = "safe"
$accountObject = "serviceaccount"
$username = "xxxxxx"
#URL for grabbing info
$uriString = "https://" + $CCPHost + "/AIMWebService/api/Accounts?AppID=" + $appID + "&Query=Safe=" + $safe + ";Object=" + $accountObject
#grab all info presented via url
$content = Invoke-RestMethod -Method Get -Uri $uriString -ContentType application/json|Select-Object -Property *
$pass = ($content).content
$password = $pass | ConvertTo-SecureString -asPlainText -Force
$mycreds = New-Object Management.Automation.PSCredential ("[email protected]", $password)
Write-Host "Removing $user access from $path" -foregroundcolor Red
Start-Process powershell.exe -Credential $mycreds -ArgumentList "icacls $path /remove $user /T"Output:
Start-Process : This command cannot be run due to the error: The user name or password is incorrect.
At C:\Scripts\FullPermissions.ps1:33 char:1
+ Start-Process powershell.exe -Credential $mycreds -ArgumentList "icac ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException
+ FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
04-29-2022 03:59 AM
You aren't really doing any validation on whether the "Invoke-RestMethod" even worked. Check it's return code and return value.
04-30-2022 07:27 AM
If the REST API call to the AAM CCP URL returns the target account's correct username and password, but the action of actually using the target account credentials fails.... then it is not a CyberArk issue.
If you try to interactively "run-as" powershell.exe with the serviceusers credentials, it will probably fail also. Sounds like a (logon) permissions issue on your Windows machine.
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!

