It’s easy to use PowerShell to create a new organizational unit (OU) but how do you make sure first that an OU with that name doesn’t already exist in your Active Directory environment?
Here’s how you can do it where the OU name you want to check for is Sales
$ou = Get-ADOrganizationalUnit -Filter ‘name -eq “Sales” ‘;
if ($ou -eq $null)
{
New-ADOrganizationalUnit -name Sales;
}
Mitch Tulloch is an eleven-time recipient of the Microsoft Most Valuable Professional (MVP) award and a widely recognized expert on Windows Server and cloud computing technologies. For more information see http://www.mtit.com.