Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
function Restore-EntraDeletedDirectoryObject {
[CmdletBinding(DefaultParameterSetName = '')]
param (
[Alias('ObjectId')]
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[System.String] $Id,
[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[switch] $AutoReconcileProxyConflict
)

PROCESS {
$params = @{}
$customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand
$params["Uri"] = 'https://graph.microsoft.com/v1.0/directory/deletedItems/'
$params["Method"] = "POST"
if($null -ne $PSBoundParameters["Id"])
{
$params["Uri"] += $Id+"/microsoft.graph.restore"
}
if($PSBoundParameters.ContainsKey("AutoReconcileProxyConflict"))
{
$params["Body"] = @{
autoReconcileProxyConflict = $true
}
}

Write-Debug("============================ TRANSFORMATIONS ============================")
$params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug
Write-Debug("=========================================================================`n")

$response = Invoke-GraphRequest @params -Headers $customHeaders
if($response){
$userList = @()
foreach ($data in $response) {
$userType = New-Object Microsoft.Graph.PowerShell.Models.MicrosoftGraphDirectoryObject
$data.PSObject.Properties | ForEach-Object {
$propertyName = $_.Name
$propertyValue = $_.Value
$userType | Add-Member -MemberType NoteProperty -Name $propertyName -Value $propertyValue -Force
}
$userList += $userType
}
$userList
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
function Restore-EntraBetaDeletedDirectoryObject {
[CmdletBinding(DefaultParameterSetName = '')]
param (
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[System.String] $Id,
[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[switch] $AutoReconcileProxyConflict
)

PROCESS {
$params = @{}
$customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand
$params["Uri"] = 'https://graph.microsoft.com/beta/directory/deletedItems/'
$params["Method"] = "POST"
if($null -ne $PSBoundParameters["Id"])
{
$params["Uri"] += $Id+"/microsoft.graph.restore"
}
if($PSBoundParameters.ContainsKey("AutoReconcileProxyConflict"))
{
$params["Body"] = @{
autoReconcileProxyConflict = $true
}
}

Write-Debug("============================ TRANSFORMATIONS ============================")
$params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug
Write-Debug("=========================================================================`n")

$response = Invoke-GraphRequest @params -Headers $customHeaders
if($response){
$userList = @()
foreach ($data in $response) {
$userType = New-Object Microsoft.Graph.Beta.PowerShell.Models.MicrosoftGraphDirectoryObject
$data.PSObject.Properties | ForEach-Object {
$propertyName = $_.Name
$propertyValue = $_.Value
$userType | Add-Member -MemberType NoteProperty -Name $propertyName -Value $propertyValue -Force
}
$userList += $userType
}
$userList
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Restore a previously deleted object.
```powershell
Restore-EntraBetaDeletedDirectoryObject
-Id <String>
[-AutoReconcileProxyConflict]
[<CommonParameters>]
```

Expand Down Expand Up @@ -75,6 +76,24 @@ This example shows how to restore a deleted object in Microsoft Entra ID.

- `-Id` parameter specifies the Id of the directory object to restore.

### Example 2: Restoring a Soft-Deleted User and Removing Conflicting Proxy Addresses

```powershell
Connect-Entra -Scopes 'User.ReadWrite.All'
Restore-EntraBetaDeletedDirectoryObject -Id 'dddddddd-3333-4444-5555-eeeeeeeeeeee' -AutoReconcileProxyConflict
```

```Output
Id DeletedDateTime
-- ---------------
dddddddd-3333-4444-5555-eeeeeeeeeeee
```

This example shows how to restore a deleted object in Microsoft Entra ID.

- `-Id` parameter specifies the Id of the directory object to restore.
- `-AutoReconcileProxyConflict` parameter removes any conflicting proxy addresses while restoring a soft-deleted user whose one or more proxy addresses are currently used for an active user.

## Parameters

### -Id
Expand All @@ -93,6 +112,22 @@ Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False
```

### -AutoReconcileProxyConflict

Specifies whether Microsoft Entra ID should remove conflicting proxy addresses when restoring a soft-deleted user, if any of the user's proxy addresses are currently in use by an active user. This parameter applies only when restoring a soft-deleted user. The default value is `false`.

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False
```

### CommonParameters

This cmdlet supports the common parameters: `-Debug`, `-ErrorAction`, `-ErrorVariable`, `-InformationAction`, `-InformationVariable`, `-OutVariable`, `-OutBuffer`, `-PipelineVariable`, `-Verbose`, `-WarningAction`, and `-WarningVariable`. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,24 @@ This example shows how to restore a deleted object in Microsoft Entra ID.

- `-Id` parameter specifies the Id of the directory object to restore.

### Example 2: Restoring a Soft-Deleted User and Removing Conflicting Proxy Addresses

```powershell
Connect-Entra -Scopes 'User.ReadWrite.All'
Restore-EntraDeletedDirectoryObject -Id 'dddddddd-3333-4444-5555-eeeeeeeeeeee' -AutoReconcileProxyConflict
```

```Output
Id DeletedDateTime
-- ---------------
dddddddd-3333-4444-5555-eeeeeeeeeeee
```

This example shows how to restore a deleted object in Microsoft Entra ID.

- `-Id` parameter specifies the Id of the directory object to restore.
- `-AutoReconcileProxyConflict` parameter removes any conflicting proxy addresses while restoring a soft-deleted user whose one or more proxy addresses are currently used for an active user.

## Parameters

### -Id
Expand All @@ -93,6 +111,22 @@ Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False
```

### -AutoReconcileProxyConflict

Specifies whether Microsoft Entra ID should remove conflicting proxy addresses when restoring a soft-deleted user, if any of the user's proxy addresses are currently in use by an active user. This parameter applies only when restoring a soft-deleted user. The default value is `false`.

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False
```

### CommonParameters

This cmdlet supports the common parameters: `-Debug`, `-ErrorAction`, `-ErrorVariable`, `-InformationAction`, `-InformationVariable`, `-OutVariable`, `-OutBuffer`, `-PipelineVariable`, `-Verbose`, `-WarningAction`, and `-WarningVariable`. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
Expand Down
Loading