PowerShell can be used to manage a wide variety of cloud services from Microsoft. This starts with the Azure Active Directory, Teams up to SharePoint Online. So why should I bother with the Microsoft Graph PowerShell SDK? Very briefly, it is the one-stop shop for managing Microsoft cloud services with PowerShell.
What Is the Microsoft Graph PowerShell SDK?
- Application Programming Interface (API) wrapper for the Microsoft Graph APIs - Contains PowerShell commands for automation at scale - Allows connecting to single or multiple Microsoft 365 and Azure Active Directory services
Microsoft Graph PowerShell SDK Features:
- Provides access to all the Microsoft Graph APIs - Supports PowerShell 7 and above and cross-platform - Support for modern authentication
Microsoft Graph PowerShell SDK supports PowerShell 7 and is Cross-platform:
- Microsoft Graph PowerShell module works with PowerShell 7 and later - Cross-platform support for Windows, macOS, and Linux - Compatible with Windows PowerShell 5.1
Microsoft Graph API:
- Published Version (v1.0) - Beta Version
Let's compare it once the work with PowerShell, once "Normal" and once with the Microsoft Graph. On the left you can see that we need to install the modules for each Microsoft Cloud service. On the right, we install the Microsoft Graph and then we can manage the different services. Do not pay attention to the code, it is not complete. The point of this comparison is that on the left we have to install several modules including the different connections to the cloud services.
Installing the Microsoft GraphPowerShell SDK.
- Installed a compatible version of PowerShell - Execute on a supported operating system, either Windows, macOS, and Linux - Install the NuGet provider to interact with the PowerShell Gallery - If using Windows platforms, set the execution policy to remote signed or less restrictive
You can use the following cmdlets to perform the installation (# are comments) :
#Install the NuGet Provider Install-PackageProvider -Name NuGet -Force
#Set the Execution Policy (Windows) Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
#Install into the Current User Scope Install-Module Microsoft.Graph -Scope CurrentUser
#Install into the All-User Scope Install-Module Microsoft.Graph -Scope AllUsers -Force -Verbose
#Verify the Installation Get-InstalledModule Microsoft.Graph
#Updating the Module Update-Module Microsoft.Graph
Installing the main "Microsoft.Graph" module, will install additional sub modules.
- Always install the "Microsoft.Graph.Authentication" module this is needed to establish the connection. - Only install necessary modules if necessary. - Installing the Microsoft Graph PowerShell SDK in one version of PowerShell does not install it for other
That's it for the first part. In the second part we will talk about the scopes and connect to Microsoft 365.
I hope this article was useful. Thank you for taking the time to read the article.