Last active
January 9, 2019 14:21
-
-
Save nicolonsky/6f15033ea3bad2e28bf2356bcc34281a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#requires -Modules AzureAD | |
$UsageLocation = Get-AutomationVariable -Name "UsageLocation" -ErrorAction Stop | |
$servicePrincipalConnection = Get-AutomationConnection -Name "AzureRunAsConnection" -ErrorAction Stop | |
Connect-AzureAD -TenantId $servicePrincipalConnection.TenantId -ApplicationId $servicePrincipalConnection.ApplicationId ` | |
-CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint | |
Get-AzureADUser | Where-Object{$_.UsageLocation -ne $UsageLocation} | ForEach-Object { | |
Write-Output "Set UsageLocation $UsageLocation for User $($_.UserPrincipalName)" | |
Set-AzureADUser -ObjectID $_.ObjectID -UsageLocation $UsageLocation -Verbose | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment