Solved

Exchange disable account script.

Posted on 2011-09-26
7
267 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
Comment Utility
What do you want to do, to disable just the mailbox or the whole user in AD?
0
 

Author Comment

by:IT-Darlo
Comment Utility
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
Comment Utility
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
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 

Author Comment

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

Expert Comment

by:ienaxxx
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Check out this infographic on what you need to make a good email signature that will work perfectly for your organization.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Viewers will learn the different options available in the Backstage view in Excel 2013.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now