Deactivate users in OU
Hello,
I am using Exchange 2007
I would like to deactivate users that belong to a specific OU.
I thought about that below shell command:
get-mailbox -resultsize unlimited |%{if ($_.organizationalunit -eq "company.com/company/Old/Users" -or $_.organizationalunit -eq "uk.company.com/Main/Commun/Old Users") | Set-Mailbox Disable-Mailbox
But I am really not sure about the "| Set-Mailbox Disable-Mailbox" and I have not test environnement.
could you please tell me if that command would work or help me out to make it work?
Thanks,
Graig
June 4th, 2010 9:10am
Hi,
Try this command, I think it should work for you:
Get-Mailbox -Resultsize Unlimited | Where {$_.OrganizationalUnit -eq "<OUPath>" -or $_.OrganizationalUnit -eq "<OUPath2>"} | Disable-Mailbox
In you case it should look something like this:
Get-Mailbox -Resultsize Unlimited | Where {$_.OrganizationalUnit -eq "company.com/company/Old/Users" -or $_.OrganizationalUnit -eq "uk.company.com/Main/Commun/Old Users"} | Disable-MailboxMartin Sundstrm | Microsoft Certified Trainer | MCITP: Enterprise Messaging Administrator | http://msundis.wordpress.com
Free Windows Admin Tool Kit Click here and download it now
June 4th, 2010 9:45am
Thanks Martin!
For "VIP" users I would need to add an exeption and keep their account activated.
Would you please tell me how I could from a txt file NOT deactivated vip users belonging to the OU old/users ??
Graig
June 7th, 2010 9:54am
Hi Graig,
Suggest you add one property value to the VIP mailbox users.
For Example: CustomAttribute1 ->VIP
The filter can be: {$_.OrganizationalUnit -eq "company.com/company/Old/Users" -or $_.OrganizationalUnit -eq "uk.company.com/Main/Commun/Old Users" -and $_.CustomAttribute1 -ne "VIP"}
This is easier than write a script to import value from txt file, but you have to add the value manaully.Frank Wang
Free Windows Admin Tool Kit Click here and download it now
June 8th, 2010 11:24am