Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hallo,

I'm playing around with Powershell (relative NewBie) and I'm looking for the easiest way to call a Powershell script with elevated rights from within another script.

I know of the runas verb for start-process which allows me to start a new script with a different account. My problem is, however, that under Vista (UAC active) every admin account has two access tokens, a normal privilege one and an elevated one.

If I use the runas method, the second scripts gets started under the right account but with the non-elevated access token. Is there an easy way to control this?

Thanks a lot for your help!

Ulrich

share|improve this question

Are you running PowerShell V2? If so check out the Microsoft PowerShellPack module. It has 'Start-ProcessAsAdministrator' which will run a process elevated.

share|improve this answer

You could try this: http://gallery.technet.microsoft.com/scriptcenter/63fd1c0d-da57-4fb4-9645-ea52fc4f1dfb/

This starts an elevation for the whole script.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.