Introduction
In last week’s ‘Microsoft Graph PowerShell Weirdness‘ we talked about how the number of cmdlets seems to be altered with a Get-Help cmdlet for some unknown reason. This week we will cover yet another odd issue with the Graph PowerShell module and it is a thorn in my side whenever I see mistakes like this. Unlike last week’s post where there is a bug possibly in effect, we now have a problem with Help provided by the Graph PowerShell cmdlets and I only ran into it because I started working in the Microsoft.Graph.Identity.DirectoryManagement submodule for this blog article.
Problem Examples
Here are two sample of the issue is showing that the examples in Get-Help for a cmdlet DO NOT match the cmdlet the examples are supposed to provide examples for:
The Get-Help should be displaying examples for the Test-MgContractProperty cmdlet, but instead it shows an example for the Test-mgDirectoryObjectProperty. Why is that? These cmndlet are from an entirely different PowerShell module than the cmdlet we are seeking help on.For the second example, the results are even worse:
The first three examples are for a Get cmdlet and they are duplicated, while the fourth example is also for the wrong cmdlet.
Searching for bad help – Step One
First, it should be said that not all cmdlets are like this, but I did see quite a few, which drove me to write this script.
I have written scripts in the past to analyze the Get-Help for cmdlets in terms of Examples as well Synopsis. This script follows a similar pattern, but also example the cmdlet number changes as well for one module:
$Cmdlets = Get-Command | Where Source -eq Microsoft.Graph.Identity.DirectoryManagement Foreach ($Cmdlet in $Cmdlets) { $Examples = (Get-Help $Cmdlet).Examples $StringCheck = "*"+"$Cmdlet"+"*" $CmdletCheck = $Examples -like $StringCheck Write-Host "$Cmdlet has a good example " -NoNewLine If ( $CmdletCheck ) { Write-Host "$CmdletCheck" -ForegroundColor Green } Else { Write-Host "$CmdletCheck" -ForegroundColor Yellow } }
What was found? With one module?
That covers one module, but what about all submodules for Graph?
All Modules – PowerShell Script
In this code, we perform a similar check, but look at all modules, record the number of cmdlets before and after a Get-Help while also recoding cmdlets with either good or bad examples:
$Modules = (Get-Command | Where Source -Like Microsoft.Graph.*).Source | Sort -Unique Foreach ($Module in $Modules) { $BadCmdletCount = 0 $GoodCmdletCount = 0 $Cmdlets = Get-Command | Where Source -eq $Module $CountBefore = $Cmdlets.Count Try { $Test = Get-Help $Cmdlets[0] -ErrorAction Stop } Catch { $HelpError = $True } $Cmdlets = Get-Command | Where Source -eq $Module $CountAfter = $Cmdlets.Count Write-Host "$Module - " -ForegroundColor Green -NoNewline Write-Host "$CountBefore / $CountAfter" -ForegroundColor White -NoNewline Foreach ($Cmdlet in $Cmdlets) { $Examples = (Get-Help $Cmdlet).Examples $StringCheck = "*"+"$Cmdlet"+"*" $CmdletCheck = $Examples -like $StringCheck # Write-Host "$Cmdlet has a good example " -NoNewLine If ( $CmdletCheck ) { # Write-Host "$CmdletCheck" -ForegroundColor Green $GoodCmdletCount++ } Else { # Write-Host "$CmdletCheck" -ForegroundColor Yellow $BadCmdletCount++ } } Write-Host " / $GoodCmdletCount" -ForegroundColor Green -NoNewline Write-Host " / $BadCmdletCount" -ForegroundColor Red }
Raw data from the above:
Notice the combination of the cmdlet drops as well as the number of good and bad cmdlet help that exists. As we can see, there is much improvement needed in the Get-Help for Microsoft’s Graph PowerShell module.
———————————————————————————————————–
Comments? Questions?
Feel free to leave your Comments below! Learn to more efficiently utilize PowerShell to manage Exchange Server, Exchange Online, Microsoft Defender for Office or Microsoft Purview Compliance portals by picking up frequently updated eBooks: