Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Instant Windows PowerShell

You're reading from  Instant Windows PowerShell

Product type Book
Published in Oct 2013
Publisher Packt
ISBN-13 9781849688741
Pages 54 pages
Edition 1st Edition
Languages
Author (1):
Vinith Menon Vinith Menon
Profile icon Vinith Menon

Table of Contents (7) Chapters

Instant Windows PowerShell
Credits
About the Author
About the Reviewers
www.packtpub.com
packtlib.packtpub.com
1. Instant Windows PowerShell

Quick start – configuring the default security policy in PowerShell


This section will give you an insight on the default script execution policy inbuilt in PowerShell 3.0. The execution policy determines if the PowerShell scripts' execution is disabled or enabled on the server. By default, the PowerShell script execution policy is set to Restricted in order to avoid any malicious code from running on your server; that means that scripts—including those you write yourself—won't run. You can verify the settings for your execution policy by typing the following in the PowerShell command prompt:

PS C:\> Get-ExecutionPolicy

You should now see the following screenshot:

If you want PowerShell to run any scripts that you write yourself or scripts downloaded from the Internet that have been signed by a trusted publisher, set your execution policy to RemoteSigned.

You can change the settings for your execution policy to RemoteSigned by typing the following in the PowerShell command prompt:

PS C:\> Set-ExecutionPolicy RemoteSigned

You should now see the following screenshot:

Alternatively, you can set the execution policy to All Signed / Unrestricted. Setting the execution policy to Unrestricted is insecure and not recommended in production environments.

The Set-ExecutionPolicy cmdlet changes the user preference for the Windows PowerShell execution policy by setting it in the registry HKLM\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell\ExecutionPolicy.

On a 64-bit OS, you need to run Set-ExecutionPolicy for 32-bit and 64-bit PSH separately. You can change the ExecutionPolicy setting just once by specifying it in parameter when launching PowerShell:

PS C:\> powershell.exe -ExecutionPolicy Unrestricted

In that case, the execution policy is set in the variable $env:PSExecutionPolicyPreference.

For a more detailed help on script signing, you can type in the following command in your PowerShell console:

PS C:\> Get-Help about_Signing

You should now see the following screenshot:

arrow left Previous Chapter
You have been reading a chapter from
Instant Windows PowerShell
Published in: Oct 2013 Publisher: Packt ISBN-13: 9781849688741
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}