Table of Contents
Recently, Microsoft released the Microsoft Graph PowerShell SDK V2 module, which includes numerous improvements such as simplified authentication, improved error handling, and enhanced speed. Excited to explore the latest version, I decided to give it a try.
However, when attempting to switch to the beta version due to the limited attribute retrieval in the SDK V2, I encountered the following error:
Select-MgProfile: The term ‘Select-MgProfile’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Microsoft Graph SDK V2- Functionality Change
Previously, users had to utilize Select-MgProfile beta to load beta commands and Select-MgProfile v1.0 to load v1.0 commands.
PS C:\> Select-MgProfile -Name beta
PS C:\> Get-MgProfile
Name Description
---- -----------
beta A snapshot of the Microsoft Graph beta API for the Global cloud.
PS C:\> Get-InstalledModule Microsoft.Graph | ft -AutoSize
Version Name Repository Description
------- ---- ---------- -----------
1.28.0 Microsoft.Graph PSGallery Microsoft Graph PowerShell module
However, with the introduction of MS Graph PowerShell V2, beta features can no longer be accessed directly. Instead, you need to install the MS Graph PowerShell beta module separately.
This change brings a significant benefit to users targeting the beta endpoint. Beta commands will now coexist alongside v1.0 commands, eliminating the need for using Select-MgProfile beta to load beta commands. It also allows using both v1.0 and beta cmdlets within the same script without requiring a full module reload.
Install MS Graph PowerShell Module:
To install the latest MS Graph PowerShell SDK, run the following cmdlet:
Install-Module Microsoft.Graph -AllowClobber
If you already have the MS Graph module installed and want to upgrade it to the latest version, use this cmdlet:
Update-Module Microsoft.Graph
Please note that the above command will only upgrade the V1.0 module. As mentioned earlier, you still need to install the beta module separately to use MS Graph PowerShell beta cmdlets.
To install the Microsoft Graph beta module, use the following command:
Install-Module Microsoft.Graph.Beta -AllowClobber
The beta module cmdlets will have the prefix Beta, such as Get-MgBetaUser or Get-MgBetaUserLicenseDetails.
With this change, customers targeting beta endpoint will no longer need to use Select-MgProfile beta to load beta commands as beta commands will exist side-by-side with v1.0 commands. This will also allow for mixing on v1.0 and beta commands in the same script without needing to reload the entire module.
#With v1 of the Microsoft Graph PowerShell SDK
Connect-MgGraph
Select-MgProfile beta
$BetaUsers = Get-MgUser
Select-MgProfile v1.0
$V1Users = Get-MgUser
#With v2 of the Microsoft Graph PowerShell SDK
Connect-MgGraph
$BetaUsers = Get-MgBetaUser
$V1Users = Get-MgUser
New Features and Improvements
Not a reader? Watch this related video tutorial: