Skip to content

Instantly share code, notes, and snippets.

@chrisbrownie
Created January 18, 2016 05:25
Show Gist options
  • Save chrisbrownie/d973865e1982f01fe393 to your computer and use it in GitHub Desktop.
Save chrisbrownie/d973865e1982f01fe393 to your computer and use it in GitHub Desktop.
Sets ImmutableIDs for all Office 365 users based on AD...without needing to touch anything.
function Get-ImmutableId ($a) {
[System.Convert]::ToBase64String(([guid](Get-ADUser $a -Properties ObjectGuid).ObjectGuid).ToByteArray())
}
##
## WARNING: This script does not health check anything at all.
## If you run it without knowing what it does, you
## will probably break the internet, and not in the good way.
##
Get-MsolUser -All |
Where {$_.UserPrincipalName -ilike "*@contoso.com" -and $_.ImmutableId -eq $null} |
% { $_ | Set-MsolUser -ImmutableId (Get-ImmutableId $b) }
@chrisbrownie
Copy link
Author

This script doesn't even work, where does $b come from?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment