Subject: PsExec and passwords with double quote
Posted: 18 March 2016 at 4:24pm
Hello,
The issue is that PsExec drops all arguments I've added on the argument when the password has a double quote in it. PsExec works fine with passwords that have unique special characters, but it specifically fails with the double quote. I know that when there's a double quote we have to repeat it for psExec to understand, but this behavior is weird. Please see below.
Code:
$x = read-host -prompt 'Enter something:'PSEXEC -u storeadmin -p ('"' + ($x -replace '"', '""') + '"') \\srXXX01 cmd /c TIME /T
Result:
Microsoft Windows XP [Version 5.1.2600](C) Copyright 1985-2001 Microsoft Corp.
Expectation:
Microsoft Windows XP [Version 5.1.2600](C) Copyright 1985-2001 Microsoft Corp.XX:XX <-- THE ACTUAL TIME, then EXIT as I've invoked /C in CMD
What's happening here is that '/C TIME /T' are all dropped and ignored when the password has a double quote.
I cannot afford to copy a CMD file to the remote machine, it has to be in the argument due to reasons.