20 March 2013

Powershell: Adding powershell Run-as Administrator Option

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:

You can download the reg key from here.

 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\""  

Related Posts:

  • Automating Microsoft Endpoint Full System Scan upon Infection While helping to manage Microsoft Endpoint, a former colleague suggested that I setup Endpoint to automatically run a full system scan each time an infection is detected. I googled the blog posting on it and although it is… Read More
  • Installing Microsoft Updates in the Build Post-OS There are updates that have to be installed after the OS has been installed. .Net Framework is an example. When I am building a reference image, I cannot inject the updates as packages to .Net Framework as it is not install… Read More
  • Windows Updates List There is a newer tool located here.  I have been working on writing a new script for SCCM and decided while writing it, I would take one of the functions and make it into a separate script for just retrieving windows… Read More
  • Automating the Creation of Software Update Groups in SCCM I have been working on automating the tasks of deploying Windows updates each month. You may think why is there a need for this when SCCM has the Automatic Deployment Rules. Some companies have to review the updates be… Read More
  • Local Administrator Report The firm I work at does not give users local administrator access for several reasons. We did an audit of our systems and found out several users had local administrator privileges that should not have. In order to keep tr… Read More

0 comments:

Post a Comment