Why does RUNAS command work but PSEXEC doesn't in this case?
5,166
What am I missing?
You need to run the command as the system account. That requires you to add -s
to your commmand
Your command would then be:
psexec -s \\ServerBoxMachine -u mydomain\myusername -p MyPassword1 iisreset
Author by
gardenofwine
Updated on September 18, 2022Comments
-
gardenofwine over 1 year
When I try to restart a remove IIS, I run:
runas /netonly /user:mydomain\myusername "iisreset ServerBoxMachine"
It asks me for a password and then the command is ran successfully. However, I use
PSEXEC
as below, it doesn't work:psexec \\ServerBoxMachine -u mydomain\myusername -p MyPassword1 iisreset
It comes back with
Access denied, you must be an administrator of the remote computer to use this command.
. So I rangpresult /r
to see if my login is part of the relevant security group and sure enough, it's part of theBUILTIN\Administrators
group. So theoretically, it should work.What am I missing?
-
Frank Thomas over 6 yearshave you confirmed that you can remote with psexec by executing cmd with it?
-
gardenofwine over 6 years@FrankThomas Yes, I did. I actually found the solution. See the P.S. in my post.
-
Mokubai over 6 yearsIf you found a solution it should be in an answer, not your question.
-
-
I say Reinstate Monica about 6 yearsThis executes the command in the context of the remote machine's System account. That's not necessary when executing this locally...and idea why it's required remotely?
-
Ramhound about 6 years@TwistyImpersonator The author determined that was their solution. Check the revision of the question. Only made what was an answer, submitted as an edit to a question, into an actual answer
-
I say Reinstate Monica about 6 yearsBummer. I don't doubt it works. I was just hoping to learn something useful. (Don't worry, I won't shoot the messenger.)