Delete faculty and staff AD accounts

Problem Description : 

Permanently delete employee user accounts from Active Directory (also deletes their home folder.

 

 

 Resolution : 

 

As part of the employee termination process, IT staff move Faculty and Staff accounts over to the 'Disabled Accounts' OU. After this occurs ADConnect (cipher2) for the Office 365 sync will move the account to Deleted users in the cloud. Microsoft will purge all data for the user account after 30 days.

 

After a period of time, you can clean up the disabled users locally by following these steps...

 

Note: Script cleanly deletes the Remote mailbox/User account from Exchange and removes their H: drive folder located at \\hawk\faculty_home or \\hawk\staff_home.

 

1. Move desired accounts from 'Disabled Accounts' OU to 'Disabled Accounts\Purge' OU.

2. Log into MBX1 Exchange (mailbox) server as administrator

3. Click on Exchange Management Shell from task bar.

4. At prompt, cd \batch

5. Run .\delete_expired_accounts.ps1

6. Confirm action for each user by typing Y

 

 

======================================================

 

Powershell Script - delete_expired_accounts.ps1

 

Import-Module ActiveDirectory

 

 

# $users=get-qaduser -searchroot "gdn.peachnet.edu/disabled accounts/purge"

$users=Get-ADUser -Filter * -SearchBase "OU=Purge,OU=Disabled Accounts,DC=gdn,DC=peachnet,DC=edu" -Properties *

 

$today=get-date

foreach ($i in $users)

{

       # if ($i.accountexpires -le $today -and $i.accountexpires -ne $null) 

              # {

              write-host "Deleting " $i.name $i.homedirectory

              rd $i.homedirectory -force -recurse

              Remove-RemoteMailbox -Identity $i.name -Confirm

              # Remove-Mailbox -Identity $i.name -confirm:$false -Permanent:$true

              # write-host "Would delete " $i.name $i.homedirectory

              # }

}

 

 

 

 

 Revision Date : 12/4/2019