PowerTip: Create an Organizational Unit with PowerShell


Summary: Use Windows PowerShell to create an organizational unit in Active Directory.

Hey, Scripting Guy! Question How can I use Windows PowerShell to create an OU in my Active Directory?

Hey, Scripting Guy! Answer In Windows Server 2012 R2 or Windows Server 2008 R2, use the New-ADOrganizationalUnit cmdlet.

To create a new OU at the root of Active Directory called “Divisions”:

NEW-ADOrganizationalUnit “Divisions”

If it needs to exist in different path in Active Directory, specify the path by its distinguished name:

NEW-ADOrganizationalUnit “Divisions” –path “OU=Offices,DC=Contoso,DC=local”

Comments (6)

  1. Chen V says:

    Very Useful cmdlet

  2. @chen v

    Yes.  It's a far cry than trying to do it with Vbscript.  

    I love the fact that PowerShell offers a common and simple methodology regardless of whether I am working with Exchange in Office 365 or managing files on the local drive.

    Sean

  3. Marcel K says:

    Any tips on using the dsacls to set and remove inherited permissions.

    I want to remove the inheritance mark, but keep the security, but if I remove the inheritance by pwoershell the security is removed and not kept.

    Using:

    dsacls “\$varDcOU=$varOrg,$varBase” /G “CN=$varOrg Group,OU=Groups,OU=$varOrg,$varBase:RCLCRP” /I:P

  4. Steve says:

    How would you pass a list of OU’s to New-adorganisationalunit?
    I’m thinking of using a csv and listing the names and the ou path.

    Thanks in anticipation

  5. gomzi says:

    how to add a user in organization under some organization??
    Example: Staff OU Which has HR as a OU inside it

  6. Bones says:

    I have a CS file that contains the names of 104 new employees at Contoso…how can I script PowerShell…to import the file and create each batch of users….using an Organizational Units…

Skip to main content