Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Windows PowerShell: executionpolicy (so I can run scripts)


09 Apr 2013   #1

Windows 7 Home Premium SP1 64bit
 
 
Windows PowerShell: executionpolicy (so I can run scripts)

Among my several independent study projects is Windows PowerShell 2.0. I am at the very beginning stage of writing trivial PowerShell scripts; so I would like to get off on the right foot. Ed Wilson, the Scripting Guy for Microsoft, has a number of Webcasts which I have viewed. He recommends using PowerShell as Administrator only when necessary for security reasons as a best practice.

I have found several methods which temporarily allow the running of scripts, ranging from easy to relatively difficult and from expensive to free. The way which is easiest for me at this early stage of learning is to use the following code from administrator level PowerShell.

enable running of scripts:
Code:
set-executionpolicy remotesigned
reset to default:
Code:
set-executionpolicy restricted
Testing has proven that both of these methods work. What I am trying to figure out is a method to elevate permission from within a standard (not administrator) PowerShell command line to run the script and then return to default after execution of the script. In a nut shell, can I create something like the following code to prevent the necessity of using administrator level to enable running scripts, run the script from standard mode, and then using administrator level to return to the default? (where remotesigned.ps1 elevates permission and restricted.ps1 returns to default permission)
Code:
remotesigned.ps1
<some lines of code for the script to run for testing>
restricted.ps1
Is my best practice to run the scripts from administrator with elevated permissions and then restore default permissions when done? --or-- Should I bite the bullet and use one of the more complicated signing methods to prevent the extra steps for each new script?

any ideas?

drpepper

My System SpecsSystem Spec
.

Reply

 Windows PowerShell: executionpolicy (so I can run scripts)




Thread Tools



Similar help and support threads for2: Windows PowerShell: executionpolicy (so I can run scripts)
Thread Forum
Windows Powershell Module General Discussion
Windows PowerShell Tutorials
windows powershell modules Performance & Maintenance
Getting Outlook (or Windows Live Mail) to run scripts Browsers & Mail
Windows Startup scripts.. exactly when? General Discussion
Windows Troubleshooting uses Powershell News

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 01:58 AM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33