Reputation: 9296
I have written a powershell script that installs and starts some services. It will only work if the script is run as administrator. Is there any way force a script to have those privileges?
Upvotes: 6
Views: 31272
Reputation: 72680
In the case you are using PowerShell V2 You can also do the following :
Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList '-command "Get-Service"'
This would run "Get-Service" as administrator, you can replace it with your script.
Upvotes: 11
Reputation: 3117
You might look at the answer to this question. It allows you to force something to be run as another account.
Upvotes: 0