편집

다음을 통해 공유


Get-EntraDeletedUser

Retrieves soft-deleted (recently deleted) users in Microsoft Entra ID.

Syntax

Get-EntraDeletedUser
   [-Top <Int32>]
   [-All]
   [-Filter <String>]
   [-Property <String[]>]
   [<CommonParameters>]
Get-EntraDeletedUser
   [-SearchString <String>]
   [-All]
   [-Property <String[]>]
   [<CommonParameters>]
Get-EntraDeletedUser
   -UserId <String>
   [-All]
   [-Property <String[]>]
   [<CommonParameters>]

Description

The Get-EntraDeletedUser cmdlet retrieves soft-deleted (recently deleted) users from the directory. Deleted users can be recovered within 30 days, after which they're permanently deleted.

Examples

Example 1: Get deleted users in the directory

Connect-Entra -Scopes 'User.Read.All'
Get-EntraDeletedUser | Select-Object Id, UserPrincipalName, DisplayName, AccountEnabled, DeletedDateTime, DeletionAgeInDays, UserType | Format-Table -AutoSize

Id                                   UserPrincipalName                                              DisplayName   AccountEnabled DeletedDateTime       DeletionAgeInDays UserType
--                                   -----------------                                              -----------   -------------- ---------------       ----------------- --------
dddddddd-3333-4444-5555-eeeeeeeeeeee dddddddd-3333-4444-5555-eeeeeeeeeeeeAveryS@contoso.com        Avery Smith   False          2/12/2025 1:15:34 PM  3                 Member

This example shows how to retrieve all recoverable deleted users in the Microsoft Entra ID.

Example 2: Get deleted users in the directory using All parameter

Connect-Entra -Scopes 'User.Read.All'
Get-EntraDeletedUser -All | Select-Object Id, UserPrincipalName, DisplayName, AccountEnabled, DeletedDateTime, DeletionAgeInDays, UserType | Format-Table -AutoSize

Id                                   UserPrincipalName                                              DisplayName   AccountEnabled DeletedDateTime       DeletionAgeInDays UserType
--                                   -----------------                                              -----------   -------------- ---------------       ----------------- --------
dddddddd-3333-4444-5555-eeeeeeeeeeee dddddddd-3333-4444-5555-eeeeeeeeeeeeAveryS@contoso.com        Avery Smith   False          2/12/2025 1:15:34 PM  3                 Member

This example shows how to retrieve all recoverable deleted users, using All parameter.

Example 3: Get top two deleted users

Connect-Entra -Scopes 'User.Read.All'
Get-EntraDeletedUser -Top 2 | Select-Object Id, UserPrincipalName, DisplayName, AccountEnabled, DeletedDateTime, DeletionAgeInDays, UserType | Format-Table -AutoSize

Id                                   UserPrincipalName                                              DisplayName   AccountEnabled DeletedDateTime       DeletionAgeInDays UserType
--                                   -----------------                                              -----------   -------------- ---------------       ----------------- --------
dddddddd-3333-4444-5555-eeeeeeeeeeee dddddddd-3333-4444-5555-eeeeeeeeeeeeAveryS@contoso.com        Avery Smith   False          2/12/2025 1:15:34 PM  3                 Member

This example shows how to retrieve the top two recoverable deleted users in the directory. You can use -Limit as an alias for -Top.

Example 4: Get deleted users containing string 'Avery Smith'

Connect-Entra -Scopes 'User.Read.All'
Get-EntraDeletedUser -SearchString 'Avery Smith' | Select-Object Id, UserPrincipalName, DisplayName, AccountEnabled, DeletedDateTime, DeletionAgeInDays, UserType | Format-Table -AutoSize

Id                                   UserPrincipalName                                              DisplayName   AccountEnabled DeletedDateTime       DeletionAgeInDays UserType
--                                   -----------------                                              -----------   -------------- ---------------       ----------------- --------
dddddddd-3333-4444-5555-eeeeeeeeeeee dddddddd-3333-4444-5555-eeeeeeeeeeeeAveryS@contoso.com        Avery Smith   False          2/12/2025 1:15:34 PM  3                 Member

This example shows how to retrieve deleted users in the directory, containing the specified string.

Example 5: Get deleted users filter by display name

Connect-Entra -Scopes 'User.Read.All'
Get-EntraDeletedUser -Filter "displayName eq 'Avery Smith'" | Select-Object Id, UserPrincipalName, DisplayName, AccountEnabled, DeletedDateTime, DeletionAgeInDays, UserType | Format-Table -AutoSize

Id                                   UserPrincipalName                                              DisplayName   AccountEnabled DeletedDateTime       DeletionAgeInDays UserType
--                                   -----------------                                              -----------   -------------- ---------------       ----------------- --------
dddddddd-3333-4444-5555-eeeeeeeeeeee dddddddd-3333-4444-5555-eeeeeeeeeeeeAveryS@contoso.com        Avery Smith   False          2/12/2025 1:15:34 PM  3                 Member

This example shows how to retrieve deleted users in the directory, having the specified display name.

Example 6: Get deleted user by UserId

Connect-Entra -Scopes 'User.Read.All'
Get-EntraDeletedUser -UserId 'dddddddd-3333-4444-5555-eeeeeeeeeeee' | Select-Object Id, UserPrincipalName, DisplayName, AccountEnabled, DeletedDateTime, DeletionAgeInDays, UserType | Format-Table -AutoSize

Id                                   UserPrincipalName                                              DisplayName   AccountEnabled DeletedDateTime       DeletionAgeInDays UserType
--                                   -----------------                                              -----------   -------------- ---------------       ----------------- --------
dddddddd-3333-4444-5555-eeeeeeeeeeee dddddddd-3333-4444-5555-eeeeeeeeeeeeAveryS@contoso.com        Avery Smith   False          2/12/2025 1:15:34 PM  3                 Member

This example shows how to retrieve the deleted user specified by UserId.

  • -UserId parameter specifies the deleted user UserId.

Parameters

-All

List all pages.

Type:System.Management.Automation.SwitchParameter
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Filter

Specifies an OData v4.0 filter statement. This parameter controls which objects are returned.

Type:System.String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Property

Specifies properties to be returned

Type:System.String[]
Aliases:Select
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-SearchString

Specifies a search string.

Type:System.String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Top

Specifies the maximum number of records to return.

Type:System.Int32
Aliases:Limit
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-UserId

The ObjectId or User Principal Name of the deleted user to be retrieved.

Type:System.String
Aliases:Id
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

Inputs

System.String

System.Nullable`1[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]

Outputs

System.Object