Remove-QADObject

From PowerGUI Wiki

Jump to: navigation, search

Delete the specified objects in Active Directory. Supported are both Active Directory Domain Services (AD DS) and Active Directory Lightweight Directory Services (AD LDS).

Contents

Syntax

Remove-QADObject [-Identity] <IdentityParameter> [-DeleteTree] [-Force] [-Proxy] [-Service <String>] [-ConnectionAccount <String>] [-ConnectionPassword <SecureString>] [-Credential <PSCredential>] [-Connection <ArsConnection>] [-UseGlobalCatalog] [-WhatIf] [-Confirm] [<CommonParameters>]

Detailed Description

Use this cmdlet to delete objects in Active Directory. An object to delete can be specified by DN, SID, GUID, UPN or Domain\Name, or it can be located by using a Get- cmdlet and then piped into the Remove- cmdlet (see examples).

The cmdlet has optional parameters that determine the server and the security context for the operation. Normally, the connection parameters could be omitted so far as a connection to a server is established prior to using the cmdlet. In this case, the server and the security context are determined by the Connect-QADService cmdlet.

If you do not use Connect-QADService and have no connection established prior to using a cmdlet, then the connection settings, including the server and the security context, are determined by the connection parameters of the first cmdlet you use. Subsequent cmdlets will use those settings by default.



Related Commands

Parameters

Name Description Required? Pipeline Input Default Value
Identity Specify the DN, SID, GUID, UPN or Domain\Name of the object you want to delete.

This parameter is optional since you can pipe into this cmdlet the object returned by a Get- cmdlet, to have that object identify the object to act upon.

true true (ByValue)
DeleteTree Deletes the specified object along with all child objects it contains (the entire sub-tree). If you omit this parameter, the cmdlet fails to delete container objects that hold any child objects. false false
Force Overrides restrictions that prevent the command from succeeding, just so the changes do not compromise security. false false
Proxy For parameter description, see help on the Connect-QADService cmdlet. false false
Service For parameter description, see help on the Connect-QADService cmdlet. false false
ConnectionAccount For parameter description, see help on the Connect-QADService cmdlet. false false
ConnectionPassword For parameter description, see help on the Connect-QADService cmdlet. false false
Credential For parameter description, see help on the Connect-QADService cmdlet. false false
Connection For parameter description, see help on the Connect-QADService cmdlet. false true (ByValue)
UseGlobalCatalog For parameter description, see help on the Connect-QADService cmdlet. false false
WhatIf Describes what would happen if you executed the command, without actually executing the command. false false
Confirm Prompts you for confirmation before executing the command. false false

Examples

Example 1

remove-QADObject 'MyDomain\JSmith'

Connect to any available domain controller with the credentials of the locally logged on user, bind to a specific user object by Domain\Name, and delete the object.

Example 2

get-QADUser -searchRoot 'mydomain.company.com/usersOU' | remove-QADObject -confirm

Connect to any available domain controller with the credentials of the locally logged on user, and delete all user objects that are located in a specific container.

Example 3

$pw = read-host "Enter password" -AsSecureString

C:\PS>connect-QADService -service 'localhost' -proxy -ConnectionAccount 'company\administrator' -ConnectionPassword $pw

C:\PS>remove-QADObject 'mydomain.company.com/usersOU' -deleteTree -force

C:\PS>disconnect-QADService

Connect to the local Administration Service with the credentials of a specific user, and delete a certain container along with all objects that are located in that container.

Example 4

remove-QADObject '<DN of object>' -Service 'server.domain.local:389' -Confirm

Connect to the AD LDS instance on 'server.domain.local:389' with the credentials of the locally logged on user, bind to a specific AD LDS object by DN, and delete the object.

Personal tools