# Create Multiple OUs in AD

**URL:** <https://forums.powershell.org/t/create-multiple-ous-in-ad/10814>\
**Category:** PowerShell Help\
**Created:** [June 14, 2018, 8:34am UTC](https://forums.powershell.org/t/create-multiple-ous-in-ad/10814 "2018-06-14T08:34:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![elmiraaliyeva](https://avatars.discourse-cdn.com/v4/letter/e/5daacb/32.png) [@elmiraaliyeva](https://forums.powershell.org/u/elmiraaliyeva)\
**Post date:** [June 14, 2018, 8:34am UTC](https://forums.powershell.org/t/create-multiple-ous-in-ad/10814/1 "2018-06-14T08:34:21Z")

</div>

Hi All!  
I need to create several organizational units in an existing one by import CSV file, using the command new-adorganisationalunit.  
By using this command new-adorganisationalunit -name -path I can create just one at once, how can I use this with import-csv?  
I’m new at scripting, can you help me?

---

<div class="post-metadata">

**Author:** ![will-anderson](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/will-anderson/32/234_2.png) [@will-anderson](https://forums.powershell.org/u/will-anderson)\
**Post date:** [June 14, 2018, 9:35am UTC](https://forums.powershell.org/t/create-multiple-ous-in-ad/10814/2 "2018-06-14T09:35:25Z")

</div>

Hi there Elmira,

You can import the csv to a variable and then loop through it. Something like so:

```
$csv = Import-csv -Path %PATH%
ForEach($obj in $csv){

New-ADOrganizationalUntil -Name $obj.Name 

}
```

You’ll need to map the appropriate properties (column name) to the appropriate parameter (-Parameter $Obj.ColumnName). I don’t have a working example right now, but this should get you started if you want to learn. Let us know if you have any questions.

Also, some additional information on what each parameter expects for an input: [https://technet.microsoft.com/es-es/library/hh852233(v=wps.620).aspx](https://technet.microsoft.com/es-es/library/hh852233(v=wps.620).aspx)

---

<div class="post-metadata">

**Author:** ![rob-simmers](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rob-simmers/32/1010_2.png) [@rob-simmers](https://forums.powershell.org/u/rob-simmers)\
**Post date:** [June 14, 2018, 5:31pm UTC](https://forums.powershell.org/t/create-multiple-ous-in-ad/10814/3 "2018-06-14T17:31:35Z")

</div>

Also, you should leverage the -WhatIf switch to show you what the script would do and not actually create the OU’s.

```
New-ADOrganizationalUnit-Name $obj.Name -WhatIf
```

This will let you check your work before you make changes and have to delete 100 OU’s.

---

<div class="post-metadata">

**Author:** ![will-anderson](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/will-anderson/32/234_2.png) [@will-anderson](https://forums.powershell.org/u/will-anderson)\
**Post date:** [June 15, 2018, 9:09am UTC](https://forums.powershell.org/t/create-multiple-ous-in-ad/10814/4 "2018-06-15T09:09:22Z")

</div>

^This. Read my post about PowerShell Math and the accidental creation of 2 million test accounts. 😛

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:35pm UTC](https://forums.powershell.org/t/create-multiple-ous-in-ad/10814/5 "2024-05-16T20:35:49Z")

</div>

Closed on May 16, 2024, 8:35pm UTC


