Exploring PowerShell Cmdlets

When I run into something in PowerShell that draws my curiosity, I usually go down a rabbit hole to further my knowledge of whatever that is. Sometimes this means digging into the text from the HELP for Exchange PowerShell cmdlets. For example, a while back I wrote a script to examine the text for the word ‘Deprecated’ because I Wanted to see what cmdlets were supposed to be deprecated over time. While checking out new cmdlets for Exchange Online, I ran into some cmdlets HELP that seemed to be half-way written. For the synopsis, these cmdlets showed this:

My curiosity was peaked, what other cmdlets are missing information in them. In order to find these cmdlets, I used a script I had created for the ‘Deprecated’ word check – https://justaucguy.wordpress.com/2014/12/05/exchange-2013-and-deprecated-powershell-get-commands/. I simply removed these phrases ‘cmdlet will be removed in a future version of’ / ‘cmdlet has been deprecated’ and inserted this line instead ‘Provide the topic introduction here.’

New Script

Replacing these phrases, I also added a counter just to keep track of the cmdlets. $NoSynopsis and $Synopsis provided counters for each cmdlets type:

$Name = <Server Name>
$Commands = (Get-Command | Where {$_.ModuleName -eq $Name}).Name
$Synopsis = 0
$NoSynopsis = 0
Foreach ($Line in $Commands) {
    $Synopsis = (Get-Help $Line).Synopsis
    If ($Synopsis -eq "Provide the topic introduction here.") {
       Write-Host "The cmdlet $Line has a bad synopsis" -ForegroundColor Green
       $NoSynopsis ++
    } Else {
        $Synopsis ++
Write-Host "The number of cmdlets with bad synopsi is $NoSynopsis." -ForegroundColor Red
Write-Host "The number of cmdlets with good synopsi is $Synopsis." -ForegroundColor Cyan

When the script is run, you can get these results:

In addition to this, on the same initial cmdlets I noticed that examples were also missing. Again, taking the above script, I wrote this script to look for missing Examples:

$Name = <Server Name>
$Commands = (Get-Command | Where {$_.ModuleName -eq $Name}).Name
$Examples = 0
$NoExamples = 0
Foreach ($Line in $Commands) {
    Get-Help $Line -Full > c:\downloads\command.txt
    $search = Select-String -Path c:\downloads\command.txt -Pattern "Example 1"
    if ($search -ne $null) {
        $Examples ++
    } else {
        Write-Host "The cmdlet $line has no examples." -ForegroundColor Yellow
        $NoExamples ++
    Remove-Item c:\downloads\command.txt
Write-Host "The number of cmdlets without examples is $NoExamples." -ForegroundColor Red
Write-Host "The number of cmdlets with examples is $Examples." -ForegroundColor cyan

A sample run looks likes this for Exchange:

As you can some PowerShell information is indeed missing. I would also assume that some of this will be back-filled, but others may never be updated.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s