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.
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"'