Things are changing… The Azure AD and MSOL modules will be getting a deprecated status, this was initially set for June 2022 and now that has been postponed until after December 2022. You need to start updating scripts, be prepared for that. In this blogpost I wanted to show you a way to collect all the new cmdlets and show their description, synopsis (A brief summary) and the help URL for more information.
Example of changes
The table below is an example of how the naming of the cmdlets will change for Azure AD cmdlets, there’s always a ‘Mg’ added to let you know it’s a Microsoft Graph cmdlet:
Azure AD cmdlets | Microsoft Graph PowerShell cmdlets |
---|---|
Add-AzureADDeviceRegisteredOwner | New-MgDeviceRegisteredOwnerByRef |
Add-AzureADDeviceRegisteredUser | New-MgDeviceRegisteredUserByRef |
Get-AzureADDevice | Get-MgDevice |
Get-AzureADDeviceConfiguration | Get-MgDeviceManagementDeviceConfiguration |
Get-AzureADDeviceRegisteredOwner | Get-MgDeviceRegisteredOwner |
Get-AzureADDeviceRegisteredUser | Get-MgDeviceRegisteredUser |
New-AzureADDevice | New-MgDevice |
Remove-AzureADDevice | Remove-MgDevice |
Remove-AzureADDeviceRegisteredOwner | |
Remove-AzureADDeviceRegisteredUser | |
Set-AzureADDevice | Update-MgDevice |
Requirements for the script
As said, the script should retrieve all the new cmdlets and get the description and a synopsis of them. Also a link to the help page on docs.microsocft.com should be there so that you can easily find information about the new cmdlet.
It should also install all the new Microsoft.Graph module if they are not present already, this way you will have everything ready for changing your scripts. And it should also remove any older versions so that only the current version is available for use.
After collecting all the information, the data should be saved to a CSV-file which you can use to find more information about the cmdlets.
Console output
When running the script, you should see the status while it’s installing the new modules if needed and collecting the information about the new cmdlets. This looks like this:

The CSV-file
After the script ends, you can browse to the location your specified in the $csvlocation variable and open the CSV-file. It contains about 5K lines at this moment and looks like this screenshot below:

The script
Below is the contents of the script, it has a lot of formatting parts in it. Not all information has been added to the modules yet and sometimes there is no synopsis or help URL available, also it sometimes refers to a cmdlet name without ‘Mg’ so sadly it isn’t always consistent yet. It does take about 15 minutes sometimes to get all the information and has an appetite for memory 😀
#Set Total variable to null
$total = @()
#Set CSV location
$csvlocation = 'd:\temp\Microsoft.Graph.Cmdlets.csv'
#Get a list of all available Microsoft.Graph modules
Write-host Getting a list of available online Microsoft.Graph modules... -ForegroundColor Green
$OnlineMicrosoftGraphModules = find-module -name Microsoft.Graph* | Where-Object Name -NotMatch 'Microsoft.Graph.PlusPlus' | Sort-Object Name
#Get a list of all installed Microsoft.Graph Modules
Write-host Getting a list of installed Microsoft.Graph modules... -ForegroundColor Green
$InstalledMicrosoftGraphModules = Get-InstalledModule -Name Microsoft.Graph*
#Install and import all Microsoft.Graph modules except the PlusPlus module which is for AzureAD 'work or school' accounts and 'personal' Microsoft accounts
Write-Host "Installing all Microsoft.Graph Modules but skipping is already installed..." -ForegroundColor Green
foreach ($module in $OnlineMicrosoftGraphModules) {
if (-not ($InstalledMicrosoftGraphModules -match $module.Name)) {
write-host "Installing $($module.Name)..." -ForegroundColor Green
Install-Module -Name $module.Name -ErrorAction SilentlyContinue
}
}
#Resfresh the list of all installed Microsoft.Graph Modules after installing all Microsft Graph modules
Write-host Resfreshing the list of installed Microsoft.Graph modules... -ForegroundColor Green
$InstalledMicrosoftGraphModules = Get-InstalledModule -Name Microsoft.Graph*
#Remove oldest version of Microsoft.Graph modules if there are more versions installed
Foreach ($Module in $InstalledMicrosoftGraphModules | Sort-Object Name) {
Write-Host Checking for older versions of the $Module.Name PowerShell Module and removing older versions if found... -ForegroundColor Green
$AllVersions = Get-InstalledModule -Name $Module.Name -ErrorAction:SilentlyContinue | Sort-Object PublishedDate -Descending
$MostRecentVersion = $AllVersions[0].Version
if ($AllVersions.Count -gt 1 ) {
Foreach ($Version in $AllVersions) {
if ($Version.Version -ne $MostRecentVersion) {
Write-Host "Uninstalling previous version" $Version.Version "of Module" $Module.Name -ForegroundColor Yellow
Uninstall-Module -Name $Module.Name -RequiredVersion $Version.Version -Force:$True
}
}
}
}
#retrieve all cmdlets together with the synopsis and add them to $total
foreach ($module in $InstalledMicrosoftGraphModules) {
Write-Host "Processing $($module.Name)..." -ForegroundColor Green
$cmdlets = get-command -Module $module.Name
foreach ($cmdlet in $cmdlets) {
#Retrieve Synopsis (Remove Read-Only, Read-Wite, Nullable and Supports $expand if found) and URL to docs.microsoft.com for the cmdlet
$help = Get-Help $cmdlet
$synopsis = $help.Synopsis.replace('Read-only.', '').replace('Read-Write.', '').replace('Nullable.', '').replace('Supports $expand.', '').replace('Not nullable.', '').replace('\r', " ")
$synopsis = $synopsis -replace '\n', ' ' -creplace '(?m)^\s*\r?\n', ''
#Set variable for non matching cmdlet name and synopsis content
$cmdletoldname = $cmdlet.Name.Replace('-', '-Mg')
$url = $help.relatedLinks.navigationLink.uri
#Set Synopsis or URL to "Not Available" when no data is found
if ($null -eq $synopsis -or $synopsis.Length -le 2 -or $synopsis -match $cmdletoldname -or $synopsis -match $cmdlet.Name) { $synopsis = "Not available" }
if ($null -eq $url) { $url = "Not available" }
$foundcmdlets = [PSCustomObject]@{
Source = $cmdlet.Source
Version = $cmdlet.Version
Cmdlet = $cmdlet.Name
Synopsis = $synopsis
URL = $url
}
$total += $foundcmdlets
}
}
#Save all results to the CSV location specified in the variable $CSVlocation
Write-Host Exporting results to $csvlocation -ForegroundColor Green
try {
$total | Sort-Object Source, Cmdlet | Export-Csv -Path $csvlocation -NoTypeInformation -Delimiter ';' -Encoding UTF8
}
catch {
write-host "Error saving results to $($csvlocation), please check if path is accessible" -ForegroundColor Red
}
Download the script(s) from GitHub here