Restore-RMDeletedActiveDirectoryObject
From PowerGUI Wiki
Reanimates the tombstone of a deleted Active Directory object.
Contents |
Syntax
Restore-RMDeletedActiveDirectoryObject -Name <String[]> [[-DirectoryHost] <String>] [-Partition <String>] [-Port <Int32>] [-Credential <PSCredential>] [-User <String>] [-Password <SecureString>] [-WhatIf] [-Confirm] [<CommonParameters>]
Detailed Description
Reanimates the tombstone of a deleted Active Directory object. The Restore-RMActiveDirectoryObject cmdlet does not restore object attributes to their pre-deletion state.
Related Commands
Parameters
| Name | Description | Required? | Pipeline Input | Default Value |
|---|---|---|---|---|
| Name | Specifies the relative distinguished name of the deleted object to be restored. | true | true (ByValue) | |
| DirectoryHost | Specifies the domain controller or ADAM instance host from which deleted objects are to be retrieved.
The domain controller can be specified by its computer name, IP address, or domain name. If you specify a domain name, deleted objects are retrieved from any available domain controller in the specified domain. The ADAM instance host can be specified by its computer name or IP address. If this parameter is omitted, deleted objects are retrieved from any available domain controller in the current domain. | false | true (ByValue) | |
| Partition | Specifies the distinguished name of the Active Directory partition from which deleted objects are to be retrieved. If this parameter is omitted, the default naming context is used.
This parameter is required if you specify an ADAM instance host in the DirectoryHost parameter. | false | false | |
| Port | Specifies the port number to be used for connection. If this parameter is set to 0 or not specified, the default LDAP port (389) is used. | false | false | |
| Credential | The user name and password of the user account with which you want to connect, in the form of a PSCredential object. Use the Get-Credential cmdlet provided by Windows PowerShell to pass a PSCredential object to this parameter. | false | false | |
| User | The user logon name of the account with which you want to connect, in the form Domain\UserName, or in the form of a user principal name. | false | false | |
| Password | The password of the user account with which you want to connect. The parameter value must be a SecureString object. Use the Read-Host cmdlet provided by Windows PowerShell to pass a SecureString object to this parameter. | false | false | |
| WhatIf | Describes what would happen if you executed the command without actually executing the command. | false | false | |
| Confirm | Prompts for a confirmation before executing the command. | false | false |
Examples
Example
$users = (Get-RMDeletedActiveDirectoryObject dc1.dom1.lab.local) | Where-Object { $_.Properties["objectclass"] –contains "user" }
C:\PS>foreach ($u in $users) { Restore-RMDeletedActiveDirectoryObject –Name $u.Properties["name"] –DirectoryHost dc1.dom1.lab.local }
In this example, all users deleted on the dc1.dom1.lab.local domain controller are restored.
The Get-RMDeletedActiveDirectoryObject cmdlet gets all deleted objects from the dc1.dom1.lab.local domain controller and passes them down the pipeline to the Where-Object cmdlet. Where-Object filters out the user objects and stores them in the $users variable. The Restore-RMDeletedActiveDirectoryObject cmdlet then restores each object from the $users variable.
