3

Is there a way to run a powershell script automatically in Elevated mode?

I am trying to automate some post-image tasks without user intervention, but am getting caught with the UAC. Is there a way to "bypass" this, possibly by running as another user?

I want the machine to reboot and run various scripts, so it can complete the build process with no intervention.

Cheers,

Ben

2 Answers 2

2

Startup scripts run with elevated privileges. Can you add your script to the Startup scripts in Computer Configuration/Windows Settings/Scripts (startup/Shutdown)?

I'm sure there are other ways to pass credentials but this has worked for me in the past

4
  • Is there a way to programatically add a script to the local startup scripts folder? Say I have 3 scripts to run - coul I add a line in script A to copy script B to the startup script folder and delete script A and then add a line in Script B to copy script C to the scripts folder and delete Script B?
    – Ben
    Jun 24, 2010 at 13:24
  • can you expand on this? Have added it in there, but it doesn't want to play. :-(
    – Ben
    Jun 24, 2010 at 15:51
  • Are there any errors in the event log? Where is the file loacated?
    – Dave M
    Jun 24, 2010 at 18:54
  • File is located in c:\windows\system32\grouppolicy\machine\scripts\startup (computer is back at the office so will check the log tomorrow) - Thanks, Dave. Ben
    – Ben
    Jun 24, 2010 at 19:23
0

Here is an example of a self elevating PowerShell script.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .