Move disabled user accounts with a PowerShell oneliner

Today I’ve been asked to find all disabled user accounts in a OU named “Branch Offices”.
Next, we wanted to move those accounts to an OU named “Disabled Users”.
It seems this is fairly simple by using the Search-ADAccount and Move-ADObject cmdlets:

But… what if the user objects are in a OU protected against accidental deletion? You’ll get an error:

So you could either use the GUI to remove this setting, move the users and then re-apply the setting… or you can script it:





  1. Albo Alborhane says:

    thanks a lot, it’s working well

  2. Jeff Wouters says:

    You’re welcome 🙂

Leave a Reply

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