Link to home
Start Free TrialLog in
Avatar of Robb Hill
Robb HillFlag for United States of America

asked on

Powershell and PSExec = Password failure

I have a powershell script...with a call to psexec inside of it.
So technically both tools have different character rules for a password.

I have a strange password that  is as follows  
Gy^KZwU.H6>{


The powershell and included psexc is as follows:

$Processes = Get-WmiObject -Class Win32_Process -ComputerName $Computer | ? {$_.name -like "$processname*"}
foreach ($process in $processes) {
$commandval = $process.commandline
$process2 = [WMICLASS]"\\$Computer\ROOT\CIMV2:win32_process"
$process.Terminate()
& "C:\PSTools\psexec.exe" -accepteula -i 2 "\\$Computer" -u "domain\user" -p "Gy^KZwU.H6>{"  "D:\filepath\program.bat"
}

Open in new window



Please help.  I tried inclosing the   ^ in '' and the { in '' and still failed essentially causing that user to lock out as this script loops more than 3 times.
ASKER CERTIFIED SOLUTION
Avatar of becraig
becraig
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Robb Hill

ASKER

I will try that.  Do you know if it truly passed the password that you had in the quotes?  PSExec will not throw a big error on a bad password ....which is part of the issue.  In this case the psexec continues to run...but actually passes a different password due to the special characters.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I did just have to change the password......thanks for the input everyone
Thank you both!