Install the Microsoft Graph PowerShell SDK
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
The PowerShell script execution policy must be set to
less restrictive. Use
Get-ExecutionPolicyto determine the current execution policy. For more information, see about_Execution_Policies. To set the execution policy, run:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
The Microsoft Graph PowerShell SDK comes in 2 modules, Microsoft.Graph and Microsoft.Graph.Beta, that you will install separately. These modules call the Microsoft Graph v1.0 and Microsoft Graph beta endpoints, respectively. You can install the 2 modules on the same PowerShell version.
Using the Install-Module cmdlet is the preferred installation method for the Microsoft Graph PowerShell modules.
Installing the main modules of the SDK, Microsoft.Graph and Microsoft.Graph.Beta, will install all 38 sub modules for each module. 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
Only cmdlets for the installed modules will be available for use.
To install the v1 module of the SDK in PowerShell Core or Windows PowerShell, run the following command.
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
To install the beta module, run the following command.
We recommend that you always rely on Microsoft Graph v1.0 when writing scripts. Sometimes there is a need to use the beta endpoint for testing or early adoption before a feature is available in v1.0. The Microsoft Graph beta endpoint and any functionality there is still in preview status and can change. This makes the beta endpoints unreliable for production usage since it may break existing scenarios without notice.
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.
After the installation is completed, you can verify the installed version with the following command.
To verify the installed sub-modules and their versions, run:
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.
Uninstalling the SDK
First, use the following command to uninstall the main module.
Uninstall-Module Microsoft.Graph -AllVersions
Then, remove all of the dependency modules by running the following commands.
Get-InstalledModule Microsoft.Graph.* | ? Name -ne "Microsoft.Graph.Authentication" | Uninstall-Module
Learn how to perform basic tasks with Microsoft Graph PowerShell in the Get started.