PowerShell Logo Small

Remove-ADOrganizationalUnit



This is the built-in help made by Microsoft for the command 'Remove-ADOrganizationalUnit', in PowerShell version 3 - as retrieved from Windows version 'Microsoft Windows Server 2012 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Removes an Active Directory organizational unit.

SYNTAX


Remove-ADOrganizationalUnit [-Identity] <ADOrganizationalUnit> [-AuthType <ADAuthType>] [-Credential <PSCredential>] [-Partition <String>]
[-Recursive [<SwitchParameter>]] [-Server <String>] [-Confirm [<SwitchParameter>]] [-WhatIf [<SwitchParameter>]] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Remove-ADOrganizationalUnit cmdlet removes an Active Directory organizational unit.


The Identity parameter specifies the organizational unit to remove. You can identify an organizational unit by its distinguished name (DN) or
GUID. You can also set the parameter to an organizational unit object variable, such as $<localOrganizationUnitObject> or you can pass an
object through the pipeline to the Identity parameter. For example, you can use the Get-ADOrganizationalUnit cmdlet to retrieve the object and
then pass the object through the pipeline to the Remove-ADOrganizationalUnit cmdlet.


If the object you specify to remove has child objects, you must specify the Recursive parameter.


If the ProtectedFromAccidentalDeletion property of the organizational unit object is set to true, the cmdlet returns a terminating error.


For AD LDS environments, the Partition parameter must be specified except in the following two conditions:


-The cmdlet is run from an Active Directory provider drive.


-A default naming context or partition is defined for the AD LDS environment. To specify a default naming context for an AD LDS environment,
set the msDS-defaultNamingContext property of the Active Directory directory service agent (DSA) object (nTDSDSA) for the AD LDS instance.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/?LinkID=219335
Get-ADOrganizationalUnit
New-ADOrganizationalUnit
Set-ADOrganizationalUnit

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

C:\PS>Remove-ADOrganizationalUnit -Identity "OU=Accounting,DC=FABRIKAM,DC=COM" -Recursive


Are you sure you want to remove the item and all its children?
Performing recursive remove on Target: 'OU=Accounting,DC=Fabrikam,DC=com'.
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is "Y"):y



Description

-----------

Removes an OrganizationalUnit and all of it's children. If the OrganizationalUnit is protected from deletion, then the OrganizationalUnit and
it's children will not be deleted. If the OrganizationalUnit is not protected but any of the children are, then both the OrganizationalUnit
and the children will be deleted.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>Remove-ADOrganizationalUnit -Identity "1b228aa5-2c14-48b8-ad8a-2685dc22e055" -confirm:$false



Description

-----------

Removes an OrganizationalUnit using it's objectGUID as the Identity while suppressing the confirmation prompt.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>Remove-ADOrganizationalUnit -Identity "OU=Accounting,DC=FABRIKAM,DC=COM"

Confirm
Are you sure you want to perform this action?
Performing operation "Remove" on Target "OU=Accounting,DC=Fabrikam,DC=com".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is "Y"):y



Description

-----------

Removes the Accounting OrganizationalUnit.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>Remove-ADOrganizationalUnit -Identity "OU=Managed,DC=AppNC" -server "FABRIKAM-SRV1:60000" -confirm:$false



Description

-----------

Removes an OrganizationalUnit from an LDS instance.