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

link|improve this question

77% accept rate
feedback

1 Answer

Startup scripts run with elevated privilege 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

link|improve this answer
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 '10 at 13:24
can you expand on this? Have added it in there, but it doesn't want to play. :-( – Ben Jun 24 '10 at 15:51
Are there any errors in the event log? Where is the file loacated? – Dave M Jun 24 '10 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 '10 at 19:23
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.