Weekend Scripter: Exploring New and Improved PowerShell 3.0 Cmdlets

Weekend Scripter: Exploring New and Improved PowerShell 3.0 Cmdlets

  • Comments 4
  • Likes

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 

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Power shell has to be improved and microsoft has to provide this as a default feature in the product....

  • Is there a way to have both Powershell 2, and Powershell 3 installed on a Windows 7 system for testing purposes?

  • @Ben If you install Windows Management Framework 3.0 (www.microsoft.com/.../details.aspx) on Windows 7 SP1 computer, you will get a PowerShell 2.0 engine too. It's not the same as a side-by-side experience, but more than enough for testing. Start PowerShell 2.0 engine with the following command:

    powershell -version 2

    Check a version by using $PSVersionTable variable:

    PS C:\> $PsVersionTable

    Name                                     Value

    ----                                         -----

    CLRVersion                              2.0.50727.5456

    BuildVersion                             6.1.7601.17514

    PSVersion                                2.0

    WSManStackVersion                 2.0

    PSCompatibleVersions              {1.0, 2.0}

    SerializationVersion                  1.1.0.1

    PSRemotingProtocolVersion      2.1

  • It's interesting: after installing PowerShell 3 when I execute '$psversiontable' I get

    Name                           Value

    ----                           -----

    PSVersion                      3.0

    WSManStackVersion              3.0

    SerializationVersion           1.1.0.1

    CLRVersion                     4.0.30319.17929

    BuildVersion                   6.2.9200.16398

    PSCompatibleVersions           {1.0, 2.0, 3.0}

    PSRemotingProtocolVersion      2.2

    as the result.

    But when I execute the first command in this blogpost

    Get-Command -CommandType cmdlet | Foreach-Object { get-help $_ } | select name, description | where description -match "powershell 3.0"

    it returns no results!

    So I've been gipped out of the help files!

    Help!