Remotely run a script invoking "Run As Administrator"
Is using psexec.exe an option? If so you can use it with the -h parameter.
If the target system is Vista or higher, has the process run with the account's elevated token, if available.
Related videos on Youtube
Community
Updated on September 18, 2022Comments
-
Community over 1 year
This is as close to the exact question that I have, but looks like he found another way that fits the needs so it has been marked as answered:
I have a Powershell script running on server
A
that I want to launch a different Powershell script on serverB
.The script on server
B
will run fine if I run it locally, but it has to be launched as if by theRun as Administrator
option. I can't find a way to launch the script on serverB
from serverA
that won't give me a permissions issue.So far, I've tried:
- invoke-command using a
PScreds
object with the local admin account - start-process throw a
PSSession
using the-Verb runas
flag modifying the serverB
script to "Self elevate", but it still fails fromA
- creating a batch file wrapper with
Start-process
Is there another way to try that I haven't come up with? The purpose, (in case someone has an all-around better way) is to kick off Windows Updates on server
B
from serverA
. I want to be able to do this on demand and not have aScheduled Task
that I'll eventually forget about and have trigger when I don't want it to. - invoke-command using a