Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Exchange disable account script.

Posted on 2011-09-26
7
Medium Priority
?
287 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 2000 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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 errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

916 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