I am trying to delete multiple ou's, not in the same parent\child structure but multiple OU's next to each other. Example:
OU=legal,OU=department,DC=company,DC=com
OU=marketing,OU=department,DC=company,DC=com
OU=advertising,OU=department,DC=company,DC=com
I can delete a single OU out with protection using the following:
Get-ADOrganizationalUnit -Identity 'OU=legal,OU=department,DC=company,DC=com' |
Set-ADObject -ProtectedFromAccidentalDeletion:$false -PassThru |
Remove-ADOrganizationalUnit -Confirm:$false
But I'm unsure of how to get it to work with a foreach and a text file. Any help would be greatly appreciated