I decided to install SQL Server 2008 Express and while I was resolving my prerequisite issues I noticed that one of the requirements was to have Windows PowerShell installed. I have to admit, I have never heard of Windows PowerShell at this point, I just passed this off as another utility that was included as a part of Visual Studio. Since it was a requirement for SQL Server, I installed it. A few days later as I was exploring my Programs folder I noticed an entry for Windows PowerShell, so I decided to take a look.
My first impressions were that it looked a lot like the command window (cmd.exe), until I did a “dir” command; the output was Unix/Linux-like. I then tried a couple of Unix commands such as “ls” and “ps” and surprisingly they worked! Other commands such as “grep” and “who” did not work. It looks like Microsoft had developed a shell comparable to those found on Unix/Linux and they also borrowed a lot.

PowerShell Resources
I was determined to test-drive PowerShell to see what it was capable of, and surprisingly found out that PowerShell had already been out since late 2006 and there was a lot of documentation and tutorials available. Frank Koch (Infrastructure Architect at Microsoft) developed some workshops and documentation for learning PowerShell that are available for download in both English and German. I walked through the first of his tutorials and discovered most of what you can accomplish in the shells of Unix (e.g. ksh, bash), can be accomplished with PowerShell and the syntax is very similar. Most of the commands (called cmdlets) will utilize pipes ‘|’ to redirect the output of a command to another or to a file. PowerShell also supports looping, and formatted output (i.e. csv, xml, html).
Another great site for PowerShell tutorials and resources is PowerShell Pro! One of the more useful features of the site is the Script Library, a forum where users can find/post shell scripts.
When starting to learn PowerShell commands, you will find that there is a lot more typing involved. Many of the commands will use a “verb-noun” context, for example, the equivalent of the “kill” command is “Stop-Process”. Fortunately, like in Unix, PowerShell supports the use of aliases and by default will map most of the known Unix Shell commands to their respective cmdlet. Here is a list of the built-in aliases:
| Alias |
Cmdlet |
| ac |
Add-Content |
| asnp |
Add-PSSnapin |
| clc |
Clear-Content |
| cli |
Clear-Item |
| clp |
Clear-ItemProperty |
| clv |
Clear-Variable |
| cpi |
Copy-Item |
| cpp |
Copy-ItemProperty |
| cvpa |
Convert-Path |
| diff |
Compare-Object |
| epal |
Export-Alias |
| epcsv |
Export-Csv |
| fc |
Format-Custom |
| fl |
Format-List |
| foreach |
ForEach-Object |
| ft |
Format-Table |
| fw |
Format-Wide |
| gal |
Get-Alias |
| gc |
Get-Content |
| gci |
Get-ChildItem |
| gcm |
Get-Command |
| gdr |
Get-PSDrive |
| ghy |
Get-History |
| gi |
Get-Item |
| gl |
Get-Location |
| gm |
Get-Member |
| gp |
Get-ItemProperty |
| gps |
Get-Process |
| group |
Group-Object |
| gsv |
Get-Service |
| gsnp |
Get-PSSnapin |
| gu |
Get-Unique |
| gv |
Get-Variable |
| gwmi |
Get-WmiObject |
| iex |
Invoke-Expression |
| ihy |
Invoke-History |
| ii |
Invoke-Item |
| ipal |
Import-Alias |
| ipcsv |
Import-Csv |
| mi |
Move-Item |
| mp |
Move-ItemProperty |
| nal |
New-Alias |
| ndr |
New-PSDrive |
| ni |
New-Item |
| nv |
New-Variable |
| oh |
Out-Host |
| rdr |
Remove-PSDrive |
| ri |
Remove-Item |
| rni |
Rename-Item |
| rnp |
Rename-ItemProperty |
| rp |
Remove-ItemProperty |
| rsnp |
Remove-PSSnapin |
| rv |
Remove-Variable |
| rvpa |
Resolve-Path |
| sal |
Set-Alias |
| sasv |
Start-Service |
| sc |
Set-Content |
| select |
Select-Object |
| si |
Set-Item |
| sl |
Set-Location |
| sleep |
Start-Sleep |
| sort |
Sort-Object |
| sp |
Set-ItemProperty |
| spps |
Stop-Process |
| spsv |
Stop-Service |
| sv |
Set-Variable |
| tee |
Tee-Object |
| where |
Where-Object |
| write |
Write-Output |
| cat |
Get-Content |
| cd |
Set-Location |
| clear |
Clear-Host |
| cp |
Copy-Item |
| h |
Get-History |
| history |
Get-History |
| kill |
Stop-Process |
| lp |
Out-Printer |
| ls |
Get-ChildItem |
| mount |
New-PSDrive |
| mv |
Move-Item |
| popd |
Pop-Location |
| ps |
Get-Process |
| pushd |
Push-Location |
| pwd |
Get-Location |
| r |
Invoke-History |
| rm |
Remove-Item |
| rmdir |
Remove-Item |
| echo |
Write-Output |
| cls |
Clear-Host |
| chdir |
Set-Location |
| copy |
Copy-Item |
| del |
Remove-Item |
| dir |
Get-ChildItem |
| erase |
Remove-Item |
| move |
Move-Item |
| rd |
Remove-Item |
| ren |
Rename-Item |
| set |
Set-Variable |
| type |
Get-Content |
If you use PowerShell regularly, what tasks do you find it is best suited for?
An Overview of Microsoft PowerShell
I decided to install SQL Server 2008 Express and while I was resolving my prerequisite issues I noticed that one of the requirements was to have Windows PowerShell installed. I have to admit, I have never heard of Windows PowerShell at this point, I just passed this off as another utility that was included as a part of Visual Studio. Since it was a requirement for SQL Server, I installed it. A few days later as I was exploring my Programs folder I noticed an entry for Windows PowerShell, so I decided to take a look.
My first impressions were that it looked a lot like the command window (cmd.exe), until I did a “dir” command; the output was Unix/Linux-like. I then tried a couple of Unix commands such as “ls” and “ps” and surprisingly they worked! Other commands such as “grep” and “who” did not work. It looks like Microsoft had developed a shell comparable to those found on Unix/Linux and they also borrowed a lot.
PowerShell Resources
I was determined to test-drive PowerShell to see what it was capable of, and surprisingly found out that PowerShell had already been out since late 2006 and there was a lot of documentation and tutorials available. Frank Koch (Infrastructure Architect at Microsoft) developed some workshops and documentation for learning PowerShell that are available for download in both English and German. I walked through the first of his tutorials and discovered most of what you can accomplish in the shells of Unix (e.g. ksh, bash), can be accomplished with PowerShell and the syntax is very similar. Most of the commands (called cmdlets) will utilize pipes ‘|’ to redirect the output of a command to another or to a file. PowerShell also supports looping, and formatted output (i.e. csv, xml, html).
Another great site for PowerShell tutorials and resources is PowerShell Pro! One of the more useful features of the site is the Script Library, a forum where users can find/post shell scripts.
When starting to learn PowerShell commands, you will find that there is a lot more typing involved. Many of the commands will use a “verb-noun” context, for example, the equivalent of the “kill” command is “Stop-Process”. Fortunately, like in Unix, PowerShell supports the use of aliases and by default will map most of the known Unix Shell commands to their respective cmdlet. Here is a list of the built-in aliases:
If you use PowerShell regularly, what tasks do you find it is best suited for?
Related Posts
Like this post? Feel free to share or bookmark it.