Reputation: 37834
I'm using a program called psExec to remotely connect to a machine and start an interactive program.
The machine I'm connecting to, does not have a password.
So if I run this:
psExec \\Computer_Name -u User -i -d calc.exe
It prompts me for a password:
Password:
I just hit enter(since the computer doesn't have a password), and it works.
I don't want to have to hit enter every time, because I am writing a script.
So I tried this:
psExec \\Computer_Name -u User -p -i -d calc.exe
and this:
psExec \\Computer_Name -u User -p"" -i -d calc.exe
and this:
psExec \\Computer_Name -u User -p'' -i -d calc.exe
and this:
psExec \\Computer_Name -u User -p "" -i -d calc.exe
and this:
psExec \\Computer_Name -u User -p '' -i -d calc.exe
but no matter what, specifying the p
flag results in a "Wrong Username or Password error."
How can I tell my script to either press enter automatically, or automate psExec to connect automatically without a password?
I'm in PowerShell if that is relevant.
Upvotes: 2
Views: 15736
Reputation: 165
Give this a shot when all else fails. It just passes a return.
Write-Host "" | psExec \\Computer_Name -u User -i -d calc.exe
Upvotes: 0
Reputation: 211
It seems to work if you put a ~ for the password in powershell.
./psexec -i -u domain\gmsa$ -p ~ notepad.exe
My use case was getting it to skip the enter keypress when using psexec to run something as a group managed service account (gMSA).
Upvotes: 1
Reputation: 667
PSEXEC is a program that is offered as a suite of tools from Microsoft. PSEXEC Link
but for security reasons this can cause some issues, you can add a second account to the machine and give it a simple password and run the script against that account, that would be the easiest way, other wise you can most likely accomplish the same task in powershell not using PSEXEC, what is it that you are trying to do and we can try help get something written.
UPDATE:
param (
[Parameter(Mandatory = $true)]
$Password
)
psExec \\OAIJCTDU8024272 -u User -p $Password -i -d calc.exe
Upvotes: 1