Weekend Scripter: Exploring New and Improved PowerShell 3.0 Cmdlets

Doctor Scripto

Summary: Microsoft Scripting Guy, Ed Wilson, goes spelunking for new and improved Windows PowerShell 3.0 cmdlets.

Microsoft Scripting Guy, Ed Wilson, is here. Today is officially the last day of my vacation. Tomorrow, early in the morning, I hop on a plane and head to Redmond, Washington for a week of meetings. This is not a bad thing because I will get to see many really cool people from the Windows PowerShell team. For a Scripting Guy, this will seem more like vacation than work. The only bad thing is that I get back right before Windows PowerShell Saturday in Charlotte.

Playing around with Get-Help to find new and improved cmdlets

I love playing around with Windows PowerShell 3.0. On weekends and when I am traveling, I open the Windows PowerShell console and begin to explore. I always return to the three most basic cmdlets when I am exploring. The three basic cmdlets I use are Get-Help, Get-Command, and Get-Member. A fourth one I always use is the Where-Object cmdlet.

Today, I decided to play around with Get-Help and see where Windows PowerShell 3.0 was specifically mentioned. I decided to do the search because I remembered seeing some cmdlets being mentioned as introduced in Windows PowerShell 3.0. Here is the command I used.

Get-Command -CommandType cmdlet | Foreach-Object { get-help $_ } |

select name, description | where description -match “powershell 3.0”

In this command (which is a single line command that I broke at the pipe character), I first use Get-Command to return only cmdlets. I pipe the returned cmdlet info objects to the Foreach-Object cmdlet and use Get-Help to obtain Help from the cmdlets. Next, I use the Select-Object cmdlet, and I choose the name and description where the description matches PowerShell 3.0.

The output was a bit difficult to read, so I decided to autosize the output and wrap the lines. To do this, I use the Format-Table cmdlet as shown here.

Get-Command -CommandType cmdlet | Foreach-Object { get-help $_ } |

select name, description | where description -match “powershell 3.0” | Format-Table -AutoSize -Wrap

Now that I have something I can read, I noticed that the Help uses the same types of language all the time when introducing a new Windows PowerShell 3.0 cmdlet or when announcing a modification to a previously existing cmdlet. Here is the text that introduces new functionality for an existing cmdlet.

Beginning in Windows PowerShell 3.0

Here is the text that introduces a new cmdlet.

This cmdlet is introduced in Windows PowerShell 3.0

Note   Today I am talking about exploring Windows PowerShell 3.0 via Get-Help and associated cmdlets. I am not writing a complete document that details all the changes in Windows PowerShell 3.0.

I then begin to explore. First, I look for modified cmdlets by using the command shown here (this command is a single command that I broke on the pipe characters for readability).

Get-Command -CommandType cmdlet | Foreach-Object { get-help $_ } |

select name, description |

where description -match “Beginning in Windows PowerShell 3.0” |

format-table -AutoSize –Wrap

The command and its associated output are shown here.

Image of command output

Next, I look for new cmdlets. Here is the command I used.

Get-Command -CommandType cmdlet | Foreach-Object { get-help $_ } |

select name, description |

where description -match “This cmdlet is introduced in Windows PowerShell 3.0” |

Format-Table -AutoSize –Wrap

The command and its associated output are shown in the image that follows.

Image of command output

Hopefully this will get you started playing around with Windows PowerShell 3.0 It comes installed on Windows 8 and Windows Server 2012. For more information about downloading it on Windows 7, Windows Server 2008, and Windows Server 2008 R2, see PowerShell 3.0 Is Now Available for Download!  

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.

Ed Wilson, Microsoft Scripting Guy 

0 comments

Discussion is closed.

Feedback usabilla icon