Remotely run a script invoking "Run As Administrator"

11,626

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.

Share:
11,626

Related videos on Youtube

Community
Author by

Community

Updated on September 18, 2022

Comments

  • Community
    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 server B.

    The script on server B will run fine if I run it locally, but it has to be launched as if by the Run as Administrator option. I can't find a way to launch the script on server B from server A 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 server B script to "Self elevate", but it still fails from A
    • 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 server A. I want to be able to do this on demand and not have a Scheduled Task that I'll eventually forget about and have trigger when I don't want it to.