Microsoft Graph PowerShell Tips and Tricks, Part 3: Installing, updating and uninstalling the Microsoft Graph PowerShell SDK

Reading Time: 3 minutes

Microsoft Graph Giraffes

The AzureADMSOnline and AzureADPreview PowerShell modules are scheduled for deprecation. The schedule has changed a couple of times. To be prepared, admins should get going with the new Microsoft Graph PowerShell SDK. However, the Microsoft Graph PowerShell SDK works differently. There's a learning curve that has proven steep. Many admins who have walked the path before you have reported many issues.

This blogpost series aims to help you on your journey. Together with Aleksandar Nikolic, a Microsoft MVP with an extensive background in PowerShell, we're providing tips and tricks on finding your way through typical questions, situations and annoyances.

After you’ve met the requirements, you can install the Microsoft Graph PowerShell SDK on your system.

Note:
The Microsoft Graph PowerShell SDK is currently available for installation on your local system, Azure Function runners, Azure Automation workers, CI/CD agents… However, it is not available in the Azure Cloud Shell in the Azure portal.

    

Installing the PowerShell SDK

You can install the Microsoft Graph PowerShell SDK, with the following line of PowerShell:

Install-Module -Name Microsoft.Graph -Scope CurrentUser

Tip!
If you’re installing the Microsoft Graph PowerShell SDK on a shared system, like a remote management server that is used by other admins as well, change the scope from CurrentUser to AllUsers and run the PowerShell command with elevated privileges. This will install the Microsoft Graph PowerShell SDK for all users.

The above line of PowerShell installs the Microsoft.Graph wrapper module and 40 Microsoft.Graph.* modules.

 

Using a scoped PowerShell SDK installation

However, you could opt to only install the PowerShell modules that are actually in scope of your work.

The Microsoft.Graph.Authentication module is always needed. Next to that, you can opt to install the following modules to gain access to the cmdlets you need, while reserving hard disk space for other things:

The PowerShell modules that should be of special interest for Azure AD admins are:

  • Graph.Identity.DirectoryManagement
  • Graph.Users
  • Graph.Groups
  • Graph.Identity.SignIns
  • Graph.Users.Actions
  • Graph.Identity.Governance
  • Graph.SchemaExtensions
  • Graph.DirectoryObjects

Use the following PowerShell command to install only these modules:

Install-Module -Name Microsoft.Graph.Authentication, Microsoft.Graph.Identity.DirectoryManagement, Microsoft.Graph.Users, Microsoft.Graph.Groups, Microsoft.Graph.Identity.SignIns, Microsoft.Graph.Users.Actions, Microsoft.Graph.Identity.Governance, Microsoft.Graph.SchemaExtensions, Microsoft.Graph.DirectoryObjects -Scope CurrentUser

Tip!
If you’re installing the Microsoft Graph PowerShell SDK on a shared system, like a remote management server that is used by other admins as well, change the scope from CurrentUser to AllUsers and run the PowerShell commands with elevated privileges. This will install the Microsoft Graph PowerShell SDK for all users.

 

Other PowerShell modules available in the Microsoft Graph PowerShell SDK are:

  • Graph.Intune
  • Graph.Planner
  • Graph.Teams
  • Graph.Applications
  • Graph.Devices.CorporateManagement
  • Graph.DeviceManagement
  • Graph.DeviceManagement.Enrolment
  • Graph.DeviceManagement.Administration
  • Graph.Bookings
  • Graph.Security
  • Graph.Mail                
  • Graph.Education
  • Graph.CloudCommunications
  • Graph.Files
  • Graph.Sites
  • Graph.People
  • Graph.CrossDeviceExperiences
  • Graph.PersonalContacts
  • Graph.Notes
  • Graph.Reports
  • Graph.Financials
  • Graph.Search
  • Graph.DeviceManagement.Functions
  • Graph.DeviceManagement.Actions
  • Graph.Compliance
  • Graph.Calendar
  • Graph.Devices.CloudPrint
  • Graph.ChangeNotifications
  • Graph.WindowsUpdates
  • Graph.Devices.ServiceAnnouncement
  • Microsoft.Graph.ManagedTenants

 

Updating the PowerShell SDK

In contrast to the AzureADMSOnline and AzureADPreview PowerShell modules, the Microsoft Graph PowerShell SDK actually supports the Update-Module cmdlet. To update the SDK, simply run the following PowerShell command:

Update-Module -Name Microsoft.Graph

Tip!
Run the above PowerShell command with elevated privileges when the Microsoft Graph PowerShell SDK is installed for all users.

 

Uninstalling the PowerShell SDK

One of the things you might want to do when you’re done with the Microsoft Graph PowerShell SDK – and believe us, we had this feeling multiple times in the past months! – is to uninstall the Microsoft Graph PowerShell SDK.

To uninstall the SDK and all the dependency modules, run the following commands: 

Uninstall-Module -Name Microsoft.Graph

Get-InstalledModule Microsoft.Graph.* | ForEach-Object { if ($_.Name -ne "Microsoft.Graph.Authentication") { Uninstall-Module $_.Name } }

Uninstall-Module Microsoft.Graph.Authentication

Tip!
Run the above commands with elevated privileges when the Microsoft Graph PowerShell SDK is installed for all users.

 

Let’s Start!

With the Microsoft Graph PowerShell SDK installed on the local system, we can start exploring the possibilities that it unlocks. To quote Windows: ‘Let’s Start!’.

leave your comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.