Skip to main content

User helpers

Search and resolution helpers for Entra users and user-linked identities.

Requires Microsoft Graph for Entra user searches. For full details and examples, run Get-Help <FunctionName> -Detailed.

Search-EntraUser is the quick-search helper for users. It is especially useful for guest identities where you only remember a fragment of the invited domain, a bit of the display name, or part of the UPN. It uses Microsoft Graph search first and then falls back to a broader substring scan so partial guest UPN fragments are less likely to be missed.

Search-EntraUser​

Find Entra users by display name, user principal name, and/or mail (Graph scopes: User.Read.All, Directory.Read.All).

Syntax

Search-EntraUser -SearchText <String> [-SearchIn <String>] [-IndexOnly] [-Detailed] [-GridView]
ParameterTypeDescriptionRequiredDefault
SearchTextStringText to search in display name, UPN, and/or mail. Pipeline accepted.Yes-
SearchInStringSearch target: DisplayName, UserPrincipalName, Mail, Any.NoAny
IndexOnlySwitchUse Graph indexed search only. Faster, but may miss guest fragments and other partial matches.NoFalse
DetailedSwitchShow match source, guest fragment, and user metadata columns.NoFalse
GridViewSwitchShow details in Out-GridView.NoFalse

Examples

Search-EntraUser -SearchText "step"
Search-EntraUser -SearchText "federica" -SearchIn DisplayName
"guest" | Search-EntraUser -SearchIn Any -GridView
Search-EntraUser -SearchText "step" -IndexOnly

Use -Detailed when you want the extra diagnostic columns like Matched By, Guest Fragment, Search Mode, and user metadata.

Remove-EntraUser​

Remove an Entra user from the tenant by user principal name (Graph scopes: User.ReadWrite.All, Directory.Read.All).

Syntax

Remove-EntraUser -UserPrincipalName <String> [-PassThru] [-WhatIf] [-Confirm]
ParameterTypeDescriptionRequiredDefault
UserPrincipalNameStringExact user principal name to remove. Pipeline accepted.Yes-
PassThruSwitchReturn the removed user details after deletion.NoFalse

Examples

Remove-EntraUser -UserPrincipalName "antonio.sala_stepsrl.org#EXT#@messita.onmicrosoft.com"
"federica.arpaia_stepsrl.it#EXT#@messita.onmicrosoft.com" | Remove-EntraUser -WhatIf
Remove-EntraUser -UserPrincipalName "antonio.sala_stepsrl.org#EXT#@messita.onmicrosoft.com" -PassThru

The command uses ShouldProcess, so -WhatIf and -Confirm are respected.