Export ImmutableID & Proxy Address
I recently had a requirement to Export ImmutableID & Proxy Address for a large number of users. The list of users was provided to me by HR. However, as expected typically in my requirement these contained the users email addresses rather than UPN. However, this is fine as typically if the Mail address is correct we can export the users correct UPN for any occurrences these doesn’t match via Exchange Online commands. The result gives us a text file for each users Immutable ID converted into a format that Active Directory uses. In addtion to a list of the users proxy addresses contained on their account at present.

How To: Export ImmutableID & Proxy Address
Firstly, you need to ensure you have the users required for this task saved into a txt file. If you would prefer to use CSV or other format then the script can easily be amended below to accommodate your requirement. Secondly, adjust any locations as applicable below to match required export location of your choosing.
$LogFile ="C:\Temp\User\Users.Log"
$Data = Get-Content "C:\Temp\User.txt"
#Connect to M365
Connect-MsolService
#Connect to Exchange Online
Connect-ExchangeOnline
#Loop All Users found in the Import Data File and log a separate text file for each user output.
foreach ($User in $Data) {
$ImmutableIDLog = ("C:\Temp\User\" + "$User" + "- ImmutableID.txt")
$EmailAddressLog = ("C:\Temp\User\" + "$User" + "- EmailAddress.txt")
$EmailUserUPN = Get-EXOMailbox -UserPrincipalName $User | Select-Object userprincipalname
$immutableID = Get-MsolUser -UserPrincipalName $EmailUserUPN.UserPrincipalName | Select-Object -ExpandProperty immutableID -ErrorAction Stop
Write-Host "Getting ImmutableID for $($User)"
if
([String]::IsNullOrEmpty($immutableID)) {
Write-Host "No Immutable ID $($User)"
$LogUser = "No Immutable ID $($User)"
$LogUser | Out-File $LogFile -Append
}
else {
[system.convert]::FromBase64String($immutableid) | %{$a += [System.String]::Format("{0:X}", $_) + " "};$result = $null;$result = $a.trimend();$result > $ImmutableIDLog
}
$EmailUser = Get-EXOMailbox -UserPrincipalName $User | Select-Object -ExpandProperty emailaddresses -ErrorAction SilentlyContinue
if
([String]::IsNullOrEmpty($EmailUser)) {
$LogEmail= Write-Host "No Email User$($EmailUser)"
$LogEmail | Out-File $LogFile -Append
}
else {
$EmailUser | Out-File $EmailAddressLog
}
Remove-Variable A,ImmutableID,EmailUser,LogUser,LogEmail,ImmutableIDLog,EmailAddressLog,EmaiUserUPN -ErrorAction SilentlyContinue
}
Please not the script above comes with no warranty and we accept not responsibilities for the actions taken during running this script.
Additional Details: Exchange
If you want to find more details please visit the attached tech net article from Microsoft for more details.
If you want to find more details out on Exchange Online please check out my other blog posts.
Please feel free to drop a comment below or share this blog post if it has helped you.
Please Leave a Comment
If the above has helped you in export Immutable ID for users and convert them into System String then please let us know by leaving a comment or feel free to share the article below. If you have any errors or require more details on anything covered then please comment.