<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Need help with powershell script. I am writing a powershell script to grab an accounts password via AIM service and then pass that credential to be used in PSCredential. in PAM Self-Hosted Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/need-help-with-powershell-script-i-am-writing-a-powershell/m-p/1378907#M62955</link>
    <description>&lt;P&gt;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. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;CODE&gt;#Variables
$CCPHost        = "aimservice.com"
$appID          = "app"
$safe           = "safe"
$accountObject  = "serviceaccount"
$username = "xxxxxx"
&amp;nbsp;
#URL for grabbing info
$uriString = "https://" + $CCPHost + "/AIMWebService/api/Accounts?AppID=" + $appID + "&amp;amp;Query=Safe=" + $safe + ";Object=" + $accountObject
&amp;nbsp;
#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
&amp;nbsp;
$mycreds = New-Object Management.Automation.PSCredential ("serviceaccount@domain.com", $password)
&amp;nbsp;
 
Write-Host "Removing $user access from $path" -foregroundcolor Red
Start-Process powershell.exe -Credential $mycreds -ArgumentList "icacls  $path  /remove $user /T"&lt;/CODE&gt;&lt;P&gt;Output: &lt;/P&gt;&lt;CODE&gt;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&lt;/CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 28 Apr 2022 17:10:50 GMT</pubDate>
    <dc:creator>twilk</dc:creator>
    <dc:date>2022-04-28T17:10:50Z</dc:date>
    <item>
      <title>Need help with powershell script. I am writing a powershell script to grab an accounts password via AIM service and then pass that credential to be used in PSCredential.</title>
      <link>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/need-help-with-powershell-script-i-am-writing-a-powershell/m-p/1378907#M62955</link>
      <description>&lt;P&gt;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. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;CODE&gt;#Variables
$CCPHost        = "aimservice.com"
$appID          = "app"
$safe           = "safe"
$accountObject  = "serviceaccount"
$username = "xxxxxx"
&amp;nbsp;
#URL for grabbing info
$uriString = "https://" + $CCPHost + "/AIMWebService/api/Accounts?AppID=" + $appID + "&amp;amp;Query=Safe=" + $safe + ";Object=" + $accountObject
&amp;nbsp;
#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
&amp;nbsp;
$mycreds = New-Object Management.Automation.PSCredential ("serviceaccount@domain.com", $password)
&amp;nbsp;
 
Write-Host "Removing $user access from $path" -foregroundcolor Red
Start-Process powershell.exe -Credential $mycreds -ArgumentList "icacls  $path  /remove $user /T"&lt;/CODE&gt;&lt;P&gt;Output: &lt;/P&gt;&lt;CODE&gt;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&lt;/CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 17:10:50 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/need-help-with-powershell-script-i-am-writing-a-powershell/m-p/1378907#M62955</guid>
      <dc:creator>twilk</dc:creator>
      <dc:date>2022-04-28T17:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with powershell script. I am writing a powershell script to grab an accounts password via AIM service and then pass that credential to be used in PSCredential.</title>
      <link>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/need-help-with-powershell-script-i-am-writing-a-powershell/m-p/1378908#M62956</link>
      <description>&lt;P&gt;You aren't really doing any validation on whether the "Invoke-RestMethod" even worked. Check it's return code and return value.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 10:59:18 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/need-help-with-powershell-script-i-am-writing-a-powershell/m-p/1378908#M62956</guid>
      <dc:creator>CyberArkAlumni</dc:creator>
      <dc:date>2022-04-29T10:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with powershell script. I am writing a powershell script to grab an accounts password via AIM service and then pass that credential to be used in PSCredential.</title>
      <link>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/need-help-with-powershell-script-i-am-writing-a-powershell/m-p/1378909#M62957</link>
      <description>&lt;P&gt;Sorry, I did include "write-host $pass" and then copy $pass into a RDP window to login.  so i can confirm the password is correct.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 11:46:08 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/need-help-with-powershell-script-i-am-writing-a-powershell/m-p/1378909#M62957</guid>
      <dc:creator>twilk</dc:creator>
      <dc:date>2022-04-29T11:46:08Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with powershell script. I am writing a powershell script to grab an accounts password via AIM service and then pass that credential to be used in PSCredential.</title>
      <link>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/need-help-with-powershell-script-i-am-writing-a-powershell/m-p/1378910#M62958</link>
      <description>&lt;P&gt;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. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Sat, 30 Apr 2022 14:27:09 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/need-help-with-powershell-script-i-am-writing-a-powershell/m-p/1378910#M62958</guid>
      <dc:creator>CyberArkAlumni</dc:creator>
      <dc:date>2022-04-30T14:27:09Z</dc:date>
    </item>
  </channel>
</rss>

