Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

How to Upgrade to Microsoft Graph PowerShell SDK v2

August 23, 2023
in Blog, Microsoft Graph, Powershell
0
ADVERTISEMENT

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. 

msx9tlkuahWSAHk29XItJ04lzoMvBaaU2JP29Z1kv0owuhMsth1Q4CVNxtVs

Upgrade to Microsoft Graph PowerShell SDK v2

If you are not upgrading from v1.x, follow the usual installation process for Graph PowerShell SDK.

You can check if you’ve installed the v1.x of Microsoft Graph PowerShell using command below:

PS C:\> Get-InstalledModule Microsoft.Graph | ft -AutoSize

Version Name            Repository Description
------- ----            ---------- -----------
1.28.0  Microsoft.Graph PSGallery  Microsoft Graph PowerShell module

To verify the installed sub-modules and their versions, run:

Get-InstalledModule | Where-Object {$_.Name -like '*graph*'}
Version Name                                            Repository
------- ----                                            ----------
1.28.0  Microsoft.Graph                                 PSGallery
1.28.0  Microsoft.Graph.Applications                    PSGallery
1.28.0  Microsoft.Graph.Authentication                  PSGallery
1.28.0  Microsoft.Graph.Bookings                        PSGallery
1.28.0  Microsoft.Graph.Calendar                        PSGallery
...

Upgrading to SDK 2.0 is easy. I recommend that you reboot your PC to make sure that PowerShell has no loaded module and then create a new Administrator session. Run the Update-Module cmdlet to fetch the Microsoft.Graph module from the PowerShell gallery and you’ll soon have SDK 2.0.

Update-Module Microsoft.Graph -Force
PS C:\> Get-InstalledModule Microsoft.Graph | ft -AutoSize

Version Name            Repository Description
------- ----            ---------- -----------
2.3.0   Microsoft.Graph PSGallery  Microsoft Graph PowerShell module

PS C:\> Get-InstalledModule | Where-Object {$_.Name -like '*graph*'}

Version Name                                            Repository
------- ----                                            ----------
2.3.0   Microsoft.Graph                                 PSGallery
2.3.0   Microsoft.Graph.Applications                    PSGallery
2.3.0   Microsoft.Graph.Authentication                  PSGallery
2.3.0   Microsoft.Graph.Bookings                        PSGallery
...

Microsoft Graph beta module

The problem is that updating the Microsoft.Graph module only updates the v1.x module. If you want to use the beta cmdlets to interact with the beta Graph endpoint, you must install the beta module separately:

To install the Microsoft Graph Beta module, use the following command:

Install-Module Microsoft.Graph.Beta -AllowClobber -Force
PS C:\> Get-InstalledModule Microsoft.Graph.Beta | ft -AutoSize

Version Name                 Repository Description
------- ----                 ---------- -----------
2.3.0   Microsoft.Graph.Beta PSGallery  Microsoft Graph PowerShell module

PS C:\> Get-InstalledModule | Where-Object {$_.Name -like '*graph.beta*'}

Version Name                                                 Repository
------- ----                                                 ----------
2.3.0   Microsoft.Graph.Beta                                 PSGallery
2.3.0   Microsoft.Graph.Beta.Applications                    PSGallery
2.3.0   Microsoft.Graph.Beta.Bookings                        PSGallery
2.3.0   Microsoft.Graph.Beta.Calendar                        PSGallery
...

The beta module cmdlets will have the prefix Beta, such as Get-MgBetaUser… By installing both modules, you can use them side by side without needing to switch profiles.

Consider a scenario where users were mixing v1.0 and beta commands, a situation where almost everything needed is available in Microsoft Graph v1 endpoint and only a couple of preview APIs that are only available in beta. With the Microsoft Graph PowerShell SDK v1, we had the following:

#With v1 of the Microsoft Graph PowerShell SDK
Connect-MgGraph
Select-MgProfile beta
$BetaUsers = Get-MgUser
Select-MgProfile v1.0
$V1Users = Get-MgUser

As you can see above, it is quite easy to miss in the middle of a script that cmdlets are using Microsoft Graph beta APIs. With Microsoft Graph PowerShell v2, keeping in mind to have both modules installed, users can accomplish the same result with the following:

#With v2 of the Microsoft Graph PowerShell SDK
Connect-MgGraph
$BetaUsers = Get-MgBetaUser
$V1Users = Get-MgUser

More details on enhancements on v2

The v2.x module will continue to use the same naming as the current v1 version to avoid breaking changes for those running their script against Microsoft Graph v1.0.  Changes will only be observed for beta. Here is an example.

-Microsoft Graph API v1.0 endpointMicrosoft Graph API Beta endpoint
Entity NamespaceMicrosoft.Graph.PowerShell.Models.UsersMicrosoft.Graph.Beta.PowerShell.Models.Users
Command NamesGet-MgUserGet-MgBetaUser
Module NamesMicrosoft.GraphMicrosoft.Graph.Beta

Speed up your automations

With the SDK now smaller, you can choose the module which better suits your needs with the new Microsoft Graph PowerShell v2. The first option, Microsoft.Graph module that targets https://graph.microsoft.com/v1.0/ and it is the home for those who only want to work with stables APIs. The second one, Microsoft.Graph.Beta that targets https://graph.microsoft.com/beta, which is where you will hit APIs we are still working on and in preview.

You can optimize your scripts even further by installing only the specific modules your scripts will use rather than the entire SDK.

Install-Module Microsoft.Graph.Users
Connect-MgGraph
$V1Users = Get-MgUser

PowerShell users will have access to smaller packages that facilitate its management and significantly speed up installation of the SDK, benefiting, but not limited to, CI/CD pipelines and automation on Azure. The installation size of the SDK is reduced by up to 34% in case of using the module targeting Microsoft Graph v1 endpoint.

Version of Microsoft Graph PowerShell SDKInstall Size
Microsoft.Graph V2968.68 MB
Microsoft.Graph V1.28.0634.67 MB (-34%)

Not a reader? Watch this related video tutorial:

5/5 - (1 vote)
Previous Post

How to Configure or Change the PowerShell Default Working Directory

Next Post

How to Connect to Graph PowerShell with Certificate Based Authentication

Related Posts

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024
Ftr19

How to Fix Windows Cannot Read the ProductKey From the Unattend Answer File in VirtualBox

July 26, 2024
Ftr25

How to Update Windows Terminal in Windows 10/11

July 26, 2024

How to Disable The Beep Sound in WSL Terminal on Windows

July 26, 2024

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Turn On uBlock Origin Extension in Chrome (2025)
  • Images Hidden Due To Mature Content Settings In CivitAI
  • Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory