Others

Find a Microsoft 365 UPN from an ImmutableID with PowerShell

Natalie TaylorNatalie Taylor Nov 25, 2026 869 views

Question details

Find the user principal name associated with a Microsoft 365 user's ImmutableID using PowerShell.

Find a Microsoft 365 UPN from an ImmutableID with 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.
Before you start

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.

Solution 1Recommended

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.

1
Install Microsoft Graph PowerShell

Open PowerShell and run: Install-Module Microsoft.Graph -Scope CurrentUser. If prompted, confirm the installation.

2
Connect to your tenant

Run Connect-MgGraph -Scopes "User.Read.All" and sign in to the appropriate Microsoft 365 tenant. Approve or request administrator consent if prompted.

3
Search for the matching user

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

4
Check the result

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.

Look up the ImmutableID with Microsoft Graph PowerShell
Accounts without an ImmutableID: Some accounts may not have an onPremisesImmutableId value. They will not match a search for an ImmutableID.
Free Microsoft Office alternative

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.

Open an exported CSV and review UPN and ImmutableID values side by side.Compatible with Microsoft Excel formats, including XLSX.Use a familiar, easy-to-navigate spreadsheet interface.Move existing Office documents into a lightweight workspace.
QA img-9

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.