Windows PowerShell is a more advanced command prompt for Windows. Windows 7 comes with PowerShell pre-installed.

Good to know


Here is information about your PowerShell profile and how to create it.

After setting up your profile you will most likely get an error message when launching PowerShell complaining about security policy. To fix it you need to adjust security policy for your current user by running the following command:

Set-ExecutionPolicy Unrestricted -Scope CurrentUser

Useful variables

Persistent command history

Enable persistent history across session by adding the following to your profile:

#Save history when exiting
Register-EngineEvent PowerShell.Exiting {
Get-History -Count 32767 | Group CommandLine | 
Foreach {$_.Group[0]} | Export-CliXml "$home\pshist.xml" } -SupportEvent
#Make sure our history is long enough
$MaximumHistoryCount = 32767
#Import history when starting up
Import-CliXml "$home\pshist.xml" | Add-History

Buffer size

To make sure your lines don't get wrap at 80 character you may want to add something like that into your profile:

   $a = (Get-Host).UI.RawUI
   $b = $a.BufferSize
   $b.Width = 1000
   $b.Height = 10000
   $a.BufferSize = $b

Search and replace from command output

Run a command and store it's content into $output variable. Then find and replace the provided regex within that $output variable.

$output = sbs -c armv5_urel_gcce4_4_1; $output -replace ':(\d+):', '($1) :'

Split Environment Variable

To split your path environment variable and print each item on a line run the following command:

$Env:Path.Split(";") | ForEach { Write-Host "$_" }