Skip to content

Instantly share code, notes, and snippets.

@nicolonsky
Created December 10, 2019 10:17
Show Gist options
  • Save nicolonsky/c0c238724ddf05691e9f28b1b041cf07 to your computer and use it in GitHub Desktop.
Save nicolonsky/c0c238724ddf05691e9f28b1b041cf07 to your computer and use it in GitHub Desktop.
Connect to Microsoft Graph with an Azure Service Principal certificate
servicePrincipalConnection = Get-AutomationConnection -Name "AzureRunAsConnection" -ErrorAction Stop
Update-MSGraphEnvironment -AuthUrl "https://login.microsoftonline.com/$($servicePrincipalConnection.TenantId)" -AppId $servicePrincipalConnection.ApplicationId
Connect-MSGraph -CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint -Quiet
Get-DeviceManagement_ManagedDevices
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment