Getting started with PowerShell

By | 2012-01-17T12:28:15+00:00 January 17th, 2012|Team Foundation Build, Team Foundation Server, Tools|0 Comments

Over the course of the years I have been asked about this new thing call PowerShell (.ps1). It not that new anymore and there are a number of different applications and administrative task that now using PowerShell as their standard command line interrupter.   To get start with PowerShell I would suggest reviewing the following links as a good base and reference:

  • Windows PowerShell Owner’s Manual
  • Scripting with Windows PowerShell


    One of my favorite free tools when working with PowerShell is PowerGUI .  The PowerGUI has good information to get started  in the help files as well.   There is a plug-in for Visual Studio (VS) located here  to work in the VS IDE.  Which make is easier to check-in your PowerShell scripts into source control as we know we all should do.  Some of the features that the VS plugin and the PowerGUI has are:

  • IntelliSense support through a custom PowerShell editor
  • Syntax highlighting and script analysis
  • Supports PowerGUI settings
  • Supports PowerGUI imported modules
  • Supports PowerGUI Snippets
  • PowerShell debugging
  • PowerGUI Console Tool Window
  • PowerShell Project Type


    One other item that trip everyone up when trying to run a .ps1 script for the first time is the execution policy.   By default the execution policy is set to Restricted.  Below are the four execution policies that govern scripting in Windows PowerShell:

  • Restricted (default). Permits interactive commands only (no scripts).
  • AllSigned. Permits scripts but requires a digital signature from a trusted publisher on all scripts and configuration files, including scripts that you write on the local computer.
  • RemoteSigned. Permits scripts but requires a digital signature from a trusted publisher on all scripts and configuration files that are downloaded from the Internet, including e-mail. A digital signature is not required for scripts that you create on the local computer.
  • Unrestricted. Permits scripts, including unsigned scripts.

    You can  find out what the execution policy is for your local workstation or server by the following:

  • Start | Run | type in PowerShell | A PowerShell command window will open
  • In the command window | Type Get-ExecutionPolicy | The execution policy will show as one of the four list above.


    To set the execution policy to run the a PowerShell script you will need to run the following command as a administrator:

  • Start Menu | Programs | Accessories | Right Click on PowerShell | Select Run As Administrator  | The PowerShell command window will open
  • Type in Set-ExecutionPolicy [one of the four above Example: Set-ExecutionPolicy Unrestricted]  | select Y [Yes] when prompted


    Having the Unrestricted Execution Policy might be the easiest why to get your script running, but it might not be the more secure method.  For more information on execution policy can be found here and here.  You can also find out by using the PowerShell help

  • Open a PowerShell command window | Type in  Get-Help Set-ExecutionPolicy


    If you want to see all of the help items you can add the –full  For example: Get-Help –full Set-ExecutionPolicy. 

    As you might have notice you can get help on any  of the PowerShell cmdlet by typing in GET-Help  [cmdlet] like in this example or by using the Get-Help about-[topics]  For example: GET-Help about_alias  or Get-Help about_Arrays.  More on About Help Topics can be found here

    For more information regarding all of the commands can be found here and here

    PowerShell is a very powerful script tool that is for build and deployment and a number of everyday administrative, development and testing tasks. Getting to know how to use PowerShell will be a great addition to anyone knowledge toolbox.

    Happy PowerShell scripting

  • About the Author:

    Leave A Comment