Jump to content

Recommended Posts

Posted

Hi

 

Don't know if this has been posted before, I work on Server 2012 domains and was wondering if there was a tool available to delete users from AD, their user area and profile in one go? Have a lot of old users to delete and its proving time consuming deleting them manually (AD account first, then user area, then profile). Or if no tool maybe a means of automating the process a bit via a script/powershell cmd.

 

Thanks

 

Techie1982

Posted

PowerShell?

 

$UsrNames = get-aduser -Filter * -SearchBase "OU=UsersToDelete,OU=Users,DC=YouDomain,DC=co,DC=uk"

 

$UsrNames | % {

remove-item $_.HomeDirectory -force -recurse

remove-aduser -identity $_. -force

}

 

so the above is a simplistic approach to removing users and the data if everything is on the one server, if the user data is on a file server then you may have to wrap the remove-item commands in an invoke-command -scriptblock affair, or ps session approach. Also would be a good idea to put in some error trapping and reporting on what is going on to a file.

 

not on a device that has PowerShell on so am not able to test this and as such is from memory, take care not to delete more than you require!

 

more information here

https://technet.microsoft.com/en-us/library/ee176938.aspx

https://technet.microsoft.com/en-gb/library/ee617206.aspx

https://technet.microsoft.com/en-gb/library/ee617241.https://blogs.technet.microsoft.com/heyscriptingguy/2011/11/30/use-powershell-to-find-and-remove-inactive-active-directory-users/

  • Thanks 1
Guest kiest90
Posted
I've used the free version of this: Cjwdev | AD Tidy in the past. It seems to be pretty good; it has the ability to find inactive both user and computer accounts and remove their home drives

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...