Solved

Exchange disable account script.

Posted on 2011-09-26
7
276 Views
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?
0
Comment
Question by:IT-Darlo
  • 5
  • 2
7 Comments
 
LVL 10

Expert Comment

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

Author Comment

by:IT-Darlo
ID: 36708214
Just disable the mailbox please mate. In AD the user needs to remain active.
0
 
LVL 10

Accepted Solution

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

"Alias","Hits","Size"
"JohnDoe","78173","163625808"
"PincoPall","24626","-1789110063"
"LucyRoss","17204","1959963618"
"FrankScaglione","15796","-55874279"

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.


HTH
Bye!
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 

Author Comment

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

Expert Comment

by:ienaxxx
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?
0
 
LVL 10

Expert Comment

by:ienaxxx
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!
0
 
LVL 10

Expert Comment

by:ienaxxx
ID: 36709723
Better:

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

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

HTH
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

790 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