Book Image

Instant Windows PowerShell

By : Vinith Menon
Book Image

Instant Windows PowerShell

By: Vinith Menon

Overview of this book

Windows PowerShell comprises numerous major features that extend its use, advance its usability, and allow you to control and manage Windows-based environments.Windows PowerShell is backward-compatible. Cmdlets, providers, modules, snap-ins, scripts, functions, and profiles that were designed for Windows PowerShell 2.0 work in Windows PowerShell 3.0 without any changes.A practical, hands-on guide that provides you with a number of clear step-by-step exercises which will help you take advantage of the real power that is Windows PowerShell.Starting by listing the New Features in PowerShell 3.0, this book goes on to break down the mystery and confusion that surrounds which feature to use and when. It will take you through a number of clear, practical sections that will help you to take advantage of PowerShell, easily and quickly.You will also learn how to use PowerShell for file and folder management in a Windows Server Environment. The book will also also show you how to use PowerShell Web Access for secure Windows Management anywhere, any time, on any device.Learn how to secure and sign the scripts you write using the script signing feature in PowerShell, understand how to use PowerShell to secure and administer a PKI environment, and discover how to use a BPA module to analyze the security integrity of a system as per Microsoft requirements. If you want to take your first step into PowerShell 3.0 to manage your Windows environment, then this is the book for you.
Table of Contents (7 chapters)

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: