Synopsis
Description
You must set the Name parameter to create a new organizational unit. When you do not specify the Path parameter, the cmdlet creates an organizational unit under the default NC head for the domain.
Method 1: Use the New-ADOrganizationalUnit cmdlet, specify the required parameters, and set any additional property values by using the cmdlet parameters.
Method 2: Use a template to create the new object. To do this, create a new organizational unit object or retrieve a copy of an existing organizational unit object and set the Instance parameter to this object. The object provided to the Instance parameter is used as a template for the new object. You can override property values from the template by setting cmdlet parameters. For examples and more information, see the Instance parameter description for this cmdlet.
Method 3: Use the Import-CSV cmdlet with the New-ADOrganizationalUnit cmdlet to create multiple Active Directory organizational unit objects. To do this, use the Import-CSV cmdlet to create the custom objects from a comma-separated value (CSV) file that contains a list of object properties. Then pass these objects through the pipeline to the New-ADOrganizationalUnit cmdlet to create the organizational unit objects.
Parameters
-AuthType
Specifies the authentication method to use. Possible values for this parameter include:
Required? false
Position? named
Default value Microsoft.ActiveDirectory.Management.AuthType.Negotiate
Accept pipeline input? false
Accept wildcard characters? false
-City <String>
Specifies the user's town or city. This parameter sets the City property of a user. The LDAP display name (ldapDisplayName) of this property is "l".
Required? false
Position? named
Default value
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Country <String>
Specifies the country or region code for the user's language of choice. This parameter sets the Country property of a user object. The LDAP Display Name (ldapDisplayName) of this property is "c". This value is not used by Windows 2000.
Required? false
Position? named
Default value
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Credential <PSCredential>
Specifies the user account credentials to use to perform this task. The default credentials are the credentials of the currently logged on user unless the cmdlet is run from an Active Directory PowerShell provider drive. If the cmdlet is run from such a provider drive, the account associated with the drive is the default.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Description <String>
Specifies a description of the object. This parameter sets the value of the Description property for the object. The LDAP Display Name (ldapDisplayName) for this property is "description".
Required? false
Position? named
Default value
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-DisplayName <String>
Specifies the display name of the object. This parameter sets the DisplayName property of the object. The LDAP Display Name (ldapDisplayName) for this property is "displayName".
Required? false
Position? named
Default value
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Instance <ADOrganizationalUnit>
Specifies an instance of an organizational unit object to use as a template for a new organizational unit object.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ManagedBy <ADPrincipal>
Specifies the user or group that manages the object by providing one of the following property values. Note: The identifier in parentheses is the LDAP display name for the property.
Required? false
Position? named
Default value
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Name <String>
Specifies the name of the object. This parameter sets the Name property of the Active Directory object. The LDAP Display Name (ldapDisplayName) of this property is "name".
Required? true
Position? 2
Default value
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-OtherAttributes <Hashtable>
Specifies object attribute values for attributes that are not represented by cmdlet parameters. You can set one or more parameters at the same time with this parameter. If an attribute takes more than one value, you can assign multiple values. To identify an attribute, specify the LDAPDisplayName (ldapDisplayName) defined for it in the Active Directory schema.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-PassThru <SwitchParameter>
Returns the new or modified object. By default (i.e. if -PassThru is not specified), this cmdlet does not generate any output.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Path <String>
Specifies the X.500 path of the Organizational Unit (OU) or container where the new object is created.
Required? false
Position? named
Default value
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-PostalCode <String>
Specifies the user's postal code or zip code. This parameter sets the PostalCode property of a user. The LDAP Display Name (ldapDisplayName) of this property is "postalCode".
Required? false
Position? named
Default value
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-ProtectedFromAccidentalDeletion <Boolean>
Specifies whether to prevent the object from being deleted. When this property is set to true, you cannot delete the corresponding object without changing the value of the property. Possible values for this parameter include:
Required? false
Position? named
Default value $true
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Server <String>
Specifies the Active Directory Domain Services instance to connect to, by providing one of the following values for a corresponding domain name or directory server. The service may be any of the following: Active Directory Lightweight Domain Services, Active Directory Domain Services or Active Directory Snapshot instance.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-State <String>
Specifies the user's or Organizational Unit's state or province. This parameter sets the State property of a User or Organizational Unit object. The LDAP display name (ldapDisplayName) of this property is "st".
Required? false
Position? named
Default value
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-StreetAddress <String>
Specifies the organizational unit's street address. This parameter sets the StreetAddress property of a organizational unit object. The LDAP display name (ldapDisplayName) of this property is "street".
Required? false
Position? named
Default value
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Confirm <SwitchParameter>
Prompts you for confirmation before running the cmdlet.
Required? false
Position? named
Default value false
Accept pipeline input? false
Accept wildcard characters? false
-WhatIf <SwitchParameter>
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Required? false
Position? named
Default value false
Accept pipeline input? false
Accept wildcard characters? false
Syntax
New-ADOrganizationalUnit [-WhatIf] [-Confirm] [-AuthType <ADAuthType>] [-City <String>] [-Country <String>] [-Credential <PSCredential>] [-Description <String>] [-DisplayName <String>] [-Instance <ADOrganizationalUnit>] [-ManagedBy <ADPrincipal>] [-Name] <String> [-OtherAttributes <Hashtable>] [-PassThru] [-Path <String>] [-PostalCode <String>] [-ProtectedFromAccidentalDeletion <Boolean>] [-Server <String>] [-State <String>] [-StreetAddress <String>] [<CommonParameters>]
This cmdlet does not work with an Active Directory Snapshot.
C:\PS>New-ADOrganizationalUnit -Name UserAccounts -Path “DC=TOSSolution,DC=COM”
Creates a new OrganizationalUnit named ‘UserAccounts’ which is protected from accidental deletion.
C:\PS>New-ADOrganizationalUnit -Name UserAccounts -Path “DC=TOSSolution,DC=COM” -ProtectedFromAccidentalDeletion $false
Creates a new OrganizationalUnit named ‘UserAccounts’ which is not protected from deletion.
C:\PS>New-ADOrganizationalUnit -Name UserAccounts -Path “DC=TOSSolution,DC=COM” -OtherAttributes @{seeAlso=”CN=HumanResourceManagers,OU=Groups,OU=Managed,DC=TOSSolution,DC=com”;managedBy=”CN=TomC,DC=TOSSolution,DC=COM”}
Creates an OrganizationalUnit name ‘UserAccounts’ which is protected from accidental deletion with properties ‘seeAlso’ and ‘managedBy’ set to the specified values.
C:\PS>$ouTemplate = Get-ADOrganizationalUnit “OU=UserAccounts,DC=TOSSolution,DC=com” -properties seeAlso,managedBy; New-ADOrganizationalUnit -name TomCReports -instance $ouTemplate
Uses the data from the OrganizationalUnit ‘OU=UserAccounts,DC=TOSSolution,DC=com’ as a template for another new OrganizationalUnit.
C:\PS>New-ADOrganizationalUnit -name “Managed” -path “DC=AppNC” -server “TOSSolution-SRV1:60000”
Creates a new OrganizationalUnit named ‘Managed’ in an LDS instance.
Get-Command New-ADOrganizationalUnit
. Get-ADOrganizationalUnit
. Remove-ADOrganizationalUnit
. Set-ADOrganizationalUnit