PowerShell Tip – How to remove AD OU and all child objects (another OUs, users, groups, computers)?


How to remove Active Directory Organizational Unit with all child objects (another OUs, users, groups, computers)? It is simple. The trick is to use Remove-ADObject -Recursive.

Get-ADOrganizationalUnit -Identity 'OU=ToDelete,DC=ad,DC=fabrikam,DC=com' |
    Set-ADOrganizationalUnit -ProtectedFromAccidentalDeletion:$false -PassThru |
    Remove-ADObject -Recursive -Confirm:$false

One response to “PowerShell Tip – How to remove AD OU and all child objects (another OUs, users, groups, computers)?”

  1. I need a powershell command that I can attach to the local machine to run daily, that will delete all user profiles and child items with auto reply

    these are a kiosk type win 10, that get full fast
    I want all users deleted daily at mid night

Leave a Reply

Your email address will not be published. Required fields are marked *

Active Directory Advanced function AlwaysOn Availability Groups AlwaysOn Failover Cluster Instances Building Cloud Cloud Cluster Cmdlet Database Deployment Design DFS Domain Controller DSC Fabric Failover Clustering File Server Group Policy Hardware Profile Host Hyper-V Installation Library Library Asset Library Server Network Operations Manager Orchestrator PowerShell PowerShell User Group PowerShell Workflow Security Service Manager SQL Server Storage System Center Template Time Time Synchronization Tips Virtual Machine Virtual Machine Manager VM Network VM Template Windows Server 2012 R2