Exchange disable account script.

Posted on 2011-09-26
Last Modified: 2012-05-12
Hi All, I have an 2007 exchange server and i need to disable over 400 accounts. I have a list of usernames in CSV so will need the script the look at the alias then disable the account.....Has anyone got a script for this?
Question by:IT-Darlo
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
LVL 10

Expert Comment

ID: 36599997
What do you want to do, to disable just the mailbox or the whole user in AD?

Author Comment

ID: 36708214
Just disable the mailbox please mate. In AD the user needs to remain active.
LVL 10

Accepted Solution

ienaxxx earned 500 total points
ID: 36708264
Given a CSV format like this:


in csvList.csv

You can use:

import-csv csvList.csv | Select Alias | disable-mailbox

OBVIOUSLY: First try with a CSV of ONE entry of a test user. Then, if evthng's ok, give it a go.

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.


Author Comment

ID: 36708815
Sorry to sound really stupid here......But i dont need the hits or size do i?
LVL 10

Expert Comment

ID: 36709179
No, it was just to contemplate the case in which your list has more than a column.

If you have full list of aliases (on one row) separated by a comma, you should use something else. is that the case?
LVL 10

Expert Comment

ID: 36709250
for example you should use something like that:

$a=get-content CsvList.csv
Foreach-Object -Inputobject $a.split(",") -process disable-mailbox $_

always test it with a single or a couple of test aliases.
HTH, bye!
LVL 10

Expert Comment

ID: 36709723

limit the output of a given number of lines from CsvList.csvwith with

$a=get-content CsvList.csv -totalcount 1


Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
CodeTwo Sync for iCloud ( automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question