20 March 2013

Powershell: Adding powershell Run-as Administrator Option

Posted By: Mick Pletcher - 9:37 AM

Share

& Comment

For some Powershell scripts, they need the elevated privileges, even when UAC is disabled. In order to do this, there are two options.
  1. Run a cmd.exe session as administrator and execute the PS1 file from the command line.
  2. Add the registry key listed below to be able to right-click on a PS1 file and run-as administrator.
All you need to do is copy the info below to a blank notepad screen and then save it as {Filename}.reg. Double-click on the reg file and the key will be added to the registry, thereby adding the run-as administrator option. Here is the reg key to add the run-as administrator option:


 Windows Registry Editor Version 5.00  

 [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\runas\command]  
 @="\"c:\\windows\\system32\\windowspowershell\\v1.0\\powershell.exe\" -noexit \"%1\""  

About Mick Pletcher

My blog is here to help solve issues I have encountered and solved, publish scripts I have written, and educate others in understanding areas that are not well covered

0 comments:

Post a Comment

Copyright © 2013 Mick's IT Blogs™ is a registered trademark.