Last active
July 27, 2022 14:13
-
-
Save JeremyTBradshaw/9bda98d97d4f67f8efaee946d2a7d877 to your computer and use it in GitHub Desktop.
Convert between Guid and ImmutableId (for Azure AD / Office 365 customers)
This file contains hidden or 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 -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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Stick these functions/aliases into your PowerShell profile for easy access to them anytime you're in there..