PowerShell For School Data Sync
When you're working with School Data Sync (SDS) and Microsoft Entra ID, performing tasks and actions in PowerShell is helpful. PowerShell enables bulk and scripted operations to be completed with ease. This article explains the setup and prerequisites to start using PowerShell with Microsoft Entra ID and School Data Sync, enabling administrators to use PowerShell as a tool to better manage their synced SDS data.
For reference, you can find here SDS PowerShell scripts.
Install the Microsoft Graph PowerShell SDK
For SDS object management in PowerShell, we recommend installing the Microsoft Graph PowerShell. To review the prerequisites and install both modules, follow these instructions:
Install the Microsoft Graph PowerShell.
Confirm Installation and Import the Module
Once installed, confirm the module is installed successfully. The command is also how you load the module into PowerShell. Loading the module into PowerShell allows you to run the cmdlets associated with the module.
To confirm the module is installed and imported into PowerShell, perform these steps:
Launch PowerShell.
Run this command to ensure the module is loaded and installed successfully.
Get-InstalledModule Microsoft.Graph
Note
The command returns the installed version, name and descritpion of the Microsoft Graph module, if it is installed on your system.
To import the Microsoft Graph module, run the following command:
Import-Module Microsoft.Graph
Connect to Microsoft Entra ID using PowerShell
Once the Modules are imported, you need to connect PowerShell to Microsoft Entra ID to run the commands associated with each module against your Microsoft Entra directory.
Note
You'll use delegated access to sign in as a user. You only need to sign in once per session.
Connect Microsoft Graph module to Microsoft Entra ID.
Connect-MgGraph -Scopes "User.Read.All","Group.ReadWrite.All"
The command prompts you to navigate to a webpage for authentication.
Select on the Next button or Sign in to proceed. It asks you for permissions and consent on behalf of your organization for connecting to Microsoft Graph PowerShell.
Enable the checkbox 'Consent on behalf of your organization' and select the Accept button.
Ater the successful verification, the PowerShell terminal displays 'Welcome to Microsoft Graph!'