Skip to content

Instantly share code, notes, and snippets.

@JeremyTBradshaw
Last active July 27, 2022 14:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JeremyTBradshaw/9bda98d97d4f67f8efaee946d2a7d877 to your computer and use it in GitHub Desktop.
Save JeremyTBradshaw/9bda98d97d4f67f8efaee946d2a7d877 to your computer and use it in GitHub Desktop.
Convert between Guid and ImmutableId (for Azure AD / Office 365 customers)
#Requires -Version 3
function ConvertFrom-GuidToImmutableId ([Guid]$Guid){
[System.Convert]::ToBase64String([Guid]::Parse($Guid).ToByteArray())
}
New-Alias -Name g2i -Value ConvertFrom-GuidToImmutableId
function ConvertFrom-ImmutableIdToGuid ([string]$ImmutableId) {
[Guid]([System.Convert]::FromBase64String($ImmutableId))
}
New-Alias -Name i2g -Value ConvertFrom-ImmutableIdToGuid
@JeremyTBradshaw
Copy link
Author

Stick these functions/aliases into your PowerShell profile for easy access to them anytime you're in there..

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