Find a Microsoft 365 UPN from an ImmutableID with PowerShell
Question details
Find the user principal name associated with a Microsoft 365 user's ImmutableID using PowerShell.

- Product
- Microsoft 365 and Microsoft Graph PowerShell
- Device & OS
- not provided
- Scenario
- A user has an ImmutableID and needs to identify the corresponding Microsoft 365 account.
- Observed behavior
- The goal is to return the matching account's user principal name.
Have the exact ImmutableID available, including its capitalization. Use an account with permission to read users in the Microsoft 365 tenant; administrator consent may be required for Microsoft Graph permissions.
Look up the ImmutableID with Microsoft Graph PowerShell
Use this method to search tenant users and return the UPN for an exact ImmutableID match.
Microsoft Graph exposes the ImmutableID as onPremisesImmutableId. This method retrieves users and filters them locally, so it may take time in a large tenant.
The older MSOnline module and Get-MsolUser command are retired; use Microsoft Graph PowerShell instead.
Open PowerShell and run: Install-Module Microsoft.Graph -Scope CurrentUser. If prompted, confirm the installation.
Run Connect-MgGraph -Scopes "User.Read.All" and sign in to the appropriate Microsoft 365 tenant. Approve or request administrator consent if prompted.
Replace the example value with the exact ImmutableID, then run: $immutableId = 'xxxxxx' Get-MgUser -All -Property UserPrincipalName,OnPremisesImmutableId | Where-Object { $_.OnPremisesImmutableId -ceq $immutableId } | Select-Object UserPrincipalName
Read the UserPrincipalName value in the PowerShell output. If no user appears, verify the ImmutableID's spelling and capitalization and confirm you connected to the correct tenant.

Review exported Microsoft 365 user data in WPS Spreadsheet
Microsoft Graph PowerShell performs the tenant lookup; WPS Office is a free, lightweight alternative for reviewing an exported user list. Its familiar spreadsheet interface and Microsoft Office format support make it easy to move existing files into your workflow.

Frequently Asked Questions
Why does the search use onPremisesImmutableId instead of ImmutableID?
Microsoft Graph names the user property onPremisesImmutableId. Include it in Get-MgUser's -Property parameter and compare it with the ImmutableID you have.
Why is the lookup returning no results?
Check that you signed in to the correct tenant with Connect-MgGraph, entered the exact value and capitalization, and have permission to read users. The account may also have no onPremisesImmutableId value.
Can I export UPNs and ImmutableIDs to a spreadsheet?
Yes. After connecting to Microsoft Graph, run Get-MgUser -All -Property UserPrincipalName,OnPremisesImmutableId | Select-Object UserPrincipalName,OnPremisesImmutableId | Export-Csv -Path users.csv -NoTypeInformation. Open users.csv in WPS Spreadsheet or Excel and handle the account data according to your organization's policies.
Can I still use Get-MsolUser for this lookup?
Get-MsolUser belongs to the retired MSOnline PowerShell module. Use Get-MgUser from Microsoft Graph PowerShell for a supported approach.




