Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update New-ADOrganizationalUnit.md #3640

Merged
merged 12 commits into from
Nov 17, 2023
90 changes: 61 additions & 29 deletions docset/winserver2022-ps/activedirectory/New-ADOrganizationalUnit.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ title: New-ADOrganizationalUnit
# New-ADOrganizationalUnit

## SYNOPSIS

Creates an Active Directory organizational unit.

## SYNTAX
Expand All @@ -24,12 +25,13 @@ New-ADOrganizationalUnit [-WhatIf] [-Confirm] [-AuthType <ADAuthType>] [-City <S
```

## DESCRIPTION

The **New-ADOrganizationalUnit** cmdlet creates an Active Directory organizational unit (OU).
You can set commonly used OU property values by using the cmdlet parameters.
**Property** values that are not associated with cmdlet parameters can be set by using the* OtherAttributes* parameter.
**Property** values that are not associated with cmdlet parameters can be set by using the *OtherAttributes* parameter.

You must set the *Name* parameter to create a new OU.
If you do not specify the *Path* parameter, the cmdlet creates an OU under the default NC head for the domain.
If you do not specify the *Path* parameter, the cmdlet creates an OU under the default NC (Naming Context) head for the domain.
baardhermansen marked this conversation as resolved.
Show resolved Hide resolved

The following methods describe how to create an object by using this cmdlet.

Expand All @@ -48,20 +50,23 @@ Then pass these objects through the pipeline to the **New-ADOrganizationalUnit**
## EXAMPLES

### Example 1: Create an OU

```
PS C:\> New-ADOrganizationalUnit -Name "UserAccounts" -Path "DC=FABRIKAM,DC=COM"
```

This command creates an OU named UserAccounts that is protected from accidental deletion.
This command creates an OU named UserAccounts that is protected from accidental deletion. Note that accidental protection is implicit.

### Example 2: Create an OU that is not protected from accidental deletion

```
PS C:\> New-ADOrganizationalUnit -Name "UserAccounts" -Path "DC=FABRIKAM,DC=COM" -ProtectedFromAccidentalDeletion $False
```

This command creates an OU named UserAccounts that is not protected from accidental deletion.

### Example 3: Create an OU that is protected from accidental deletion

```
PS C:\> New-ADOrganizationalUnit -Name "UserAccounts" -Path "DC=FABRIKAM,DC=COM" -OtherAttributes @{seeAlso="CN=HumanResourceManagers,OU=Groups,OU=Managed,DC=Fabrikam,DC=com";managedBy="CN=TomC,DC=FABRIKAM,DC=COM"}
```
Expand All @@ -70,6 +75,7 @@ This command creates an OU named UserAccounts that is protected from accidental
The **seeAlso** and **managedBy** properties are set to specified values.

### Example 4: Create an OU from a template OU

```
PS C:\> $OuTemplate = Get-ADOrganizationalUnit -Identity "OU=UserAccounts,DC=Fabrikam,DC=com" -Properties seeAlso,managedBy
PS C:\> New-ADOrganizationalUnit -Name "TomCReports" -Instance $OuTemplate
Expand All @@ -78,6 +84,7 @@ PS C:\> New-ADOrganizationalUnit -Name "TomCReports" -Instance $OuTemplate
This command uses the data from the OU OU=UserAccounts,DC=Fabrikam,DC=com as a template for another OU.

### Example 5: Create an OU in an AD LDS instance

```
PS C:\> New-ADOrganizationalUnit -Name "Managed" -Path "DC=AppNC" -Server "FABRIKAM-SRV1:60000"
```
Expand All @@ -87,6 +94,7 @@ This command creates an OU named Managed in an AD LDS instance.
## PARAMETERS

### -AuthType

Specifies the authentication method to use.
The acceptable values for this parameter are:

Expand All @@ -111,9 +119,10 @@ Accept wildcard characters: False
```

### -City

Specifies the town or city.
This parameter sets the **City** property of an OU object.
The Lightweight Directory Access Protocol (LDAP) display name (**ldapDisplayName**) of this property is l.
The Lightweight Directory Access Protocol (LDAP) display name (**ldapDisplayName**) of this property is `l`.

```yaml
Type: String
Expand All @@ -128,6 +137,7 @@ Accept wildcard characters: False
```

### -Confirm

Prompts you for confirmation before running the cmdlet.

```yaml
Expand All @@ -143,9 +153,10 @@ Accept wildcard characters: False
```

### -Country

Specifies the country or region code.
This parameter sets the **Country** property of an OU object.
The LDAP display name (**ldapDisplayName**) of this property is c.
The LDAP display name (**ldapDisplayName**) of this property is `c`.
This value is not used by Windows 2000.

```yaml
Expand All @@ -161,11 +172,12 @@ Accept wildcard characters: False
```

### -Credential

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.

To specify this parameter, you can type a user name, such as User1 or Domain01\User01 or you can specify a **PSCredential** object.
To specify this parameter, you can type a user name, such as `User1` or `Domain01\User01` or you can specify a **PSCredential** object.
If you specify a user name for this parameter, the cmdlet prompts for a password.

You can also create a **PSCredential** object by using a script or by using the **Get-Credential** cmdlet.
Expand All @@ -186,9 +198,10 @@ Accept wildcard characters: False
```

### -Description

Specifies a description of the object.
This parameter sets the value of the **Description** property for the OU object.
The LDAP display name (**ldapDisplayName**) for this property is description.
The LDAP display name (**ldapDisplayName**) for this property is `description`.

```yaml
Type: String
Expand All @@ -203,9 +216,10 @@ Accept wildcard characters: False
```

### -DisplayName

Specifies the display name of the object.
This parameter sets the **DisplayName** property of the OU object.
The LDAP display name (**ldapDisplayName**) for this property is displayName.
The LDAP display name (**ldapDisplayName**) for this property is `displayName`.

```yaml
Type: String
Expand All @@ -220,6 +234,7 @@ Accept wildcard characters: False
```

### -Instance

Specifies an instance of an OU object to use as a template for a new OU object.

You can use an instance of an existing OU object as a template or you can construct a new OU object by using the Windows PowerShell command line or by using a script.
Expand All @@ -232,7 +247,8 @@ You can override property values of the new object by setting the appropriate pa
Method 2: Create a new **ADOrganizationalUnit** object and set the property values by using the Windows PowerShell command line interface.
Then pass this object to the *Instance* parameter of the **New-ADOrganizationalUnit** cmdlet to create the new Active Directory OU object.

Note: Specified attributes are not validated, so attempting to set attributes that do not exist or cannot be set raises an error.
> [!NOTE]
> Specified attributes are not validated, so attempting to set attributes that do not exist or cannot be set raises an error.

```yaml
Type: ADOrganizationalUnit
Expand All @@ -247,16 +263,17 @@ Accept wildcard characters: False
```

### -ManagedBy

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.
The acceptable values for this parameter are:

- A distinguished name
- A GUID (objectGUID)
- A security identifier (objectSid)
- A GUID (objectGUID)
- A security identifier (objectSid)
- A SAM account name (sAMAccountName)

This parameter sets the Active Directory attribute with an LDAP display name of managedBy.
This parameter sets the Active Directory attribute with an LDAP display name of `managedBy`.

```yaml
Type: ADPrincipal
Expand All @@ -271,9 +288,10 @@ Accept wildcard characters: False
```

### -Name

Specifies the name of the object.
This parameter sets the **Name** property of the OU object.
The LDAP display name (**ldapDisplayName**) of this property is name.
The LDAP display name (**ldapDisplayName**) of this property is `name`.

```yaml
Type: String
Expand All @@ -288,6 +306,7 @@ Accept wildcard characters: False
```

### -OtherAttributes

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.
Expand All @@ -297,11 +316,11 @@ To specify a single value for an attribute:

`-OtherAttributes @{'AttributeLDAPDisplayName'=value}`

To specify multiple values for an attribute:
To specify multiple values for an attribute, separate the values with a comma:

`-OtherAttributes @{'AttributeLDAPDisplayName'=value1,value2,...}`

To specify values for multiple attributes:
To specify values for multiple attributes, separate the attributes with a semi-colon:

`-OtherAttributes @{'Attribute1LDAPDisplayName'=value; 'Attribute2LDAPDisplayName'=value1,value2;...}`

Expand All @@ -318,6 +337,7 @@ Accept wildcard characters: False
```

### -PassThru

Returns an object representing the item with which you are working.
By default, this cmdlet does not generate any output.

Expand All @@ -334,6 +354,7 @@ Accept wildcard characters: False
```

### -Path

Specifies the X.500 path of the OU or container where the new object is created.

In many cases, a default value is used for the *Path* parameter if no value is specified.
Expand All @@ -342,22 +363,24 @@ Note that rules listed first are evaluated first and when a default value can be

In Active Directory Domain Services (AD DS) environments, a default value for *Path* is set in the following cases:

- If the cmdlet is run from an Active Directory PowerShell provider drive, the parameter is set to the current path of the provider drive.
- If the cmdlet is run from an Active Directory PowerShell provider drive, the parameter is set to the current path of the provider drive.
- If the cmdlet has a default path, this is used.
For example: in New-ADUser, the *Path* parameter defaults to the Users container.
- If none of the previous cases apply, the default value of *Path* is set to the default partition or naming context of the target domain.
For example: in New-ADUser, the *Path* parameter defaults to the Users container.
- If none of the previous cases apply, the default value of *Path* is set to the default partition or naming context of the target domain.

In AD LDS environments, a default value for *Path* is set in the following cases:

- If the cmdlet is run from an Active Directory module for PowerShell provider drive, the parameter is set to the current path of the provider drive.
- If the cmdlet is run from an Active Directory module for PowerShell provider drive, the parameter is set to the current path of the provider drive.
- If the cmdlet has a default path, this is used.
For example: in New-ADUser, the *Path* parameter defaults to the Users container.
For example: in New-ADUser, the *Path* parameter defaults to the Users container.
- If the target AD LDS instance has a default naming context, the default value of *Path* is set to the default naming context.
To specify a default naming context for an AD LDS environment, set the **msDS-defaultNamingContext** property of the Active Directory directory service agent object (**nTDSDSA**) for the AD LDS instance.
To specify a default naming context for an AD LDS environment, set the **msDS-defaultNamingContext** property of the Active Directory directory service agent object (**nTDSDSA**) for the AD LDS instance.
- If none of the previous cases apply, the *Path* parameter does not take any default value.

Note: The Active Directory Provider cmdlets, such as **New-Item**, **Remove-Item**, **Remove-ItemProperty**, **Rename-Item**, and **Set-ItemProperty**, also contain a **Path** property.
However, for the Active Directory Provider cmdlets, the *Path* parameter identifies the path of the actual object rather than the container.
> [!NOTE]
> The Active Directory Provider cmdlets, such as **New-Item**, **Remove-Item**, **Remove-ItemProperty**, **Rename-Item**, and **Set-ItemProperty**, also contain a **Path** property.
>
> However, for the Active Directory Provider cmdlets, the *Path* parameter identifies the path of the actual object rather than the container.

```yaml
Type: String
Expand All @@ -372,9 +395,10 @@ Accept wildcard characters: False
```

### -PostalCode

Specifies the postal code or zip code.
This parameter sets the **PostalCode** property of an OU object.
The LDAP display name (**ldapDisplayName**) of this property is postalCode.
The LDAP display name (**ldapDisplayName**) of this property is `postalCode`.

```yaml
Type: String
Expand All @@ -389,6 +413,7 @@ Accept wildcard characters: False
```

### -ProtectedFromAccidentalDeletion

Indicates 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.
The acceptable values for this parameter are:
Expand All @@ -409,6 +434,7 @@ Accept wildcard characters: False
```

### -Server

Specifies the AD DS 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: AD LDS, AD DS, or Active Directory snapshot instance.

Expand Down Expand Up @@ -444,9 +470,10 @@ Accept wildcard characters: False
```

### -State

Specifies a state or province.
This parameter sets the **State** property of an OU object.
The LDAP display name (**ldapDisplayName**) of this property is st.
The LDAP display name (**ldapDisplayName**) of this property is `st`.

```yaml
Type: String
Expand All @@ -461,9 +488,10 @@ Accept wildcard characters: False
```

### -StreetAddress

Specifies a street address.
This parameter sets the **StreetAddress** property of an OU object.
The LDAP display name (**ldapDisplayName**) of this property is street.
The LDAP display name (**ldapDisplayName**) of this property is `street`.

```yaml
Type: String
Expand All @@ -478,6 +506,7 @@ Accept wildcard characters: False
```

### -WhatIf

Shows what would happen if the cmdlet runs.
The cmdlet is not run.

Expand All @@ -494,22 +523,26 @@ 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).

## INPUTS

### None or Microsoft.ActiveDirectory.Management.ADOrganizationalUnit

An OU object that is a template for the new OU object is received by the *Instance* parameter.

## OUTPUTS

### None or Microsoft.ActiveDirectory.Management.ADOrganizationalUnit

Returns the new OU object when the *PassThru* parameter is specified.
By default, this cmdlet does not generate any output.

## NOTES
* This cmdlet does not work with an Active Directory snapshot.
* This cmdlet does not work with a read-only domain controller.

- This cmdlet does not work with an Active Directory snapshot.
- This cmdlet does not work with a read-only domain controller.

## RELATED LINKS

Expand All @@ -518,4 +551,3 @@ By default, this cmdlet does not generate any output.
[Remove-ADOrganizationalUnit](./Remove-ADOrganizationalUnit.md)

[Set-ADOrganizationalUnit](./Set-ADOrganizationalUnit.md)