Introduction
There are days where I feel like I live in PowerShell and it’s those days that end up resulting in the strangest finds. Then on top of that are the finds so strange that I have to investigate it, which then results in blog posts like today. One that my mind would not leave alone until I wrote a PowerShell script to perform some analysis … and even with this first batch complete, I find myself wondering what I else I could dig up.
So what was found you may ask? Well, simply put, it was my pursuit of Microsoft Graph PowerShell, the need to get my head around it and the fact that I’ve already posted five or more articles to this very blog on the module. This current issue seems like a bug and one I do not believe at this time is repeatable with any other PowerShell Module. As a numbers person, I like sometimes check to see how many cmdlets there are in a PowerShell and what I found was a weird and only found this issue by chance.
The Issue
With a simple repeatable process, we can reveal two different cmdlet counts of most of the submodules of the Graph PowerShell module. Now, you may be wondering how that may be. Aren’t cmdlet counts for PowerShell modules normally stable? The only time they should change is when Microsoft adds or remove cmdlets from the PowerShell module. Normally I would agree 100%, to illustrate the issue I have a series of steps you can use to see this change:
(1) For any Graph submodule module, run this PowerShell:
$Cmdlets = Get-Command | Where Source -eq <module Name> $Cmdlets.Count
(2) Then run a Get-Help for ANY cmdlet in that Graph submodule:
Get-Help Get-MgContact
(3) Then perform step 1 again and you will see that the numbers are reduced, sometimes drastically:
$Cmdlets = Get-Command | Where Source -eq <module Name> $Cmdlets.Count
Results from these code blocks:
Counterbalance
Just to be sure, I ran this section of code, every few minutes to see of it was a timing issue or something, which it is not. Code ran:
(Get-Command | Where Source -eq <module Name>).Count
Code Results:
As we can see, the cmdlet count did not change.
All Graph Module Results
When checking all submodules for the Graph PowerShell module, this is what we find this
As we can see, there is a reduction in most of the submodules. Why? I don’t have an acceptable answer. Maybe someone else can validate this scenario? I will be reporting it to Microsoft in the next few days.
Notable information:: Grand Totals of all modules once Get-Help has access a cmdlet.
Cmdlets before Get-Help: 9196
Cmdlets after Get-Help: 4682
Conclusion
As we can see above, Graph PowerShell is not in a good place. Please make sure to report any issues you find so that Microsoft may fix errors like this.
———————————————————————————————————–
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: