Install the Microsoft Graph PowerShell SDK

The Microsoft Graph PowerShell SDK is published on the PowerShell Gallery. In this article you will learn how to install the Microsoft Graph PowerShell SDK using PowerShellGet.

Prerequisites

PowerShell 7 and later is the recommended PowerShell version for use with the Microsoft Graph PowerShell SDK on all platforms. There are no additional prerequisites to use the SDK with PowerShell 7 or later.

The following prerequisites are required to use the Microsoft Graph PowerShell SDK with Windows PowerShell.

  • Upgrade to PowerShell 5.1 or later

  • Install .NET Framework 4.7.2 or later

  • Update PowerShellGet to the latest version using Install-Module PowerShellGet

  • The PowerShell script execution policy must be set to remote signed or less restrictive. Use Get-ExecutionPolicy to determine the current execution policy. For more information, see about_Execution_Policies. To set the execution policy, run:

    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
    

Installation

Using the Install-Module cmdlet is the preferred installation method for the Microsoft Graph PowerShell module.

Note

Installing the main module of the SDK, Microsoft.Graph, will install all 38 sub modules. Consider only installing the necessary modules, including Microsoft.Graph.Authentication which is installed by default when you opt to install the sub modules individually. For a list of available Microsoft Graph modules, use Find-Module Microsoft.Graph*. Only cmdlets for the installed modules will be available for use.

Run the following command to install the SDK in PowerShell Core or Windows PowerShell.

Install-Module Microsoft.Graph -Scope CurrentUser

Optionally, you can change the scope of the installation using the -Scope parameter. This requires admin permissions.

Install-Module Microsoft.Graph -Scope AllUsers

Installing the SDK in one version of PowerShell does not install it for the other. Run the installation command inside the version of PowerShell you intend to use it in.

Verify installation

After the installation is completed, you can verify the installed version with the following command.

Get-InstalledModule Microsoft.Graph

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

Get-InstalledModule

The version in the output should match the latest version published on the PowerShell Gallery. Now you're ready to use the SDK.

Updating the SDK

You can update the SDK and all of its dependencies using the following command.

Update-Module Microsoft.Graph

Uninstalling the SDK

First, use the following command to uninstall the main module.

Uninstall-Module Microsoft.Graph

Then, remove all of the dependency modules by running the following commands.

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

Next steps

Learn how to perform basic tasks with Microsoft Graph PowerShell in the Get started.