Let’s get started!
The script is built from two files, first is the script (bulkdelete.ps1) and second is text file containing a list of users (users.txt).
Note: disable-mailbox will remove the user mailbox only and will keep the Active Directory account,
If you need to delete both the mailbox and the user account use remove-mailbox.
To run the script save the following to a file called bulkdelete.ps1
Get-Content c:\scripts\users.txt |disable-mailbox
Create a test file called users.txt with the list of users that look like this:
Copy both files to the same directory.
Run the script: