executing Script under elevated rights on Windows 2008 R2

rated by 0 users
This post has 1 Reply | 2 Followers

Top 500 Contributor
Posts 3
klemery Posted: 01-21-2010 7:59 PM

I have created a script to change the Pagefile size as part of an automated postinstallation script for newly built servers.  This script runs perfect when you open CMD windows using "Run as Administrator".  but does not have permissions even when run with an account that is in the local admin group.

Is there a way in the script to specifiy elevated rights like this?  I can see this being an issue running administrative script on Win2008 remotely also.

Any assistance would be helpful. Thanks in advance.

Top 10 Contributor
Posts 242
Microsoft MVP
Top Contributor

You could use Start-Process to start elevated PowerShell console and run any command/scriptblock:

Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList '-command "Get-Process"'

Page 1 of 1 (2 items) | RSS
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.