If your Windows environments have migrated to Exchange 2007, you know that the use of the Exchange Management Shell has become a critical part of system administration. One of the topics that go along with de-provisioning an account is how to handle the e-mail account.
For some environments, you can retain the Windows account for a new hire once the e-mail account is archived. With Exchange 2007, this task would require the use of the shell interface to retain the account and remove the e-mail attributes. The other action would be the full removal of the Windows account and the Exchange mailbox. This functionality is important, as some organizations do not provide all employees e-mail.
To remove the e-mail attribute from the Windows account yet retain the account, you can run either of these scripts from an Exchange Management Shell environment:
disable-mailbox -Identity Windows.Username
This will remove the Exchange mailbox attributes from the account and remove the mailbox from the database. Some additional parameters can be added to the command, such as specifying the domain controller to write the changes to the user account objects and to be confirmed of each change before it is committed.
The other scenario for scripting the removal of the Exchange mailbox would also remove the Windows account from Active Directory. This is a more permanent task, and it is more common when there is no need to retain the Windows account. Both of the samples below show how to do this:
remove-mailbox -Identity User.Name
The two scenarios can be scripted out in large amounts with normal batch files. A common way to make these scripts is a concatenated formula within an Excel spreadsheet that requires only the username or e-mail address to be added to create the command, which would be copied and pasted to save or run in the Exchange Management Shell.
Stay on top of the latest Windows Server tips and tricks with our free Windows Server newsletter, delivered each Wednesday. Automatically sign up today!
Rick Vanover is a software strategy specialist for Veeam Software, based in Columbus, Ohio. Rick has years of IT experience and focuses on virtualization, Windows-based server administration, and system hardware.