Jump to content

Recommended Posts

Posted

Hello,

I am currently looking how to do a bulk run of the attribute "msExchHideFromAddressLists" to "TRUE"., but for users within a certain OU such as leavers.

 

Anyone have a script to do this in bulk as currently 1 by 1 is tedious?

 

Thanks

Posted

If the users are in 1 OU and the OU contains only leavers then in Exchange Mgt Console -just filter Mailboxes based on OU (or even easier - sort by OU column) and the select all or shift select, right click, properties and change Attribute.

If the OU contains other users as well - then if working from a known list of usernames - yes powershell is easier. 1 other method we have used; as part of the leaving process we change 1 of the custom attributes of the user to "leaver" and then again in Exchg Mgt console you can create a filter and get only those mail boxes with CustomAttributeX = leaver and again select all and edit properties.

Posted (edited)

You can do it from the Exchange Management shell using;

 

 

$CSV = Import-CSV C:\CSVPATH\csv.csv

foreach ($u in $CSV) {

Get-Mailbox -identity $u | Set-Mailbox -HiddenFromAddressListsEnabled $true

}

 

To make this work you would need a CSV with all the users you want to affect, but if they are in a single OU you can do each OU with;

 

 

 

Get-ADUser -SearchBase OU=OUNAME,DC=DOAMIN,DC=LOCAL' -Filter '*' | select -exp samaccountname,userprincipalname | Export-CSV C:\Destiantion\csv.csv -notypeinformation

Edited by jdell
Posted
You can do it from the Exchange Management shell using;

 

 

$CSV = Import-CSV C:\CSVPATH\csv.csv

foreach ($u in $CSV) {

Get-Mailbox -identity $u | Set-Mailbox -HiddenFromAddressListsEnabled $true

}

 

To make this work you would need a CSV with all the users you want to affect, but if they are in a single OU you can do each OU with;

 

 

 

Get-ADUser -SearchBase OU=OUNAME,DC=DOAMIN,DC=LOCAL' -Filter '*' | select -exp samaccountname,userprincipalname | Export-CSV C:\Destiantion\csv.csv -notypeinformation

 

Or if you've got the AD module on your exchange box then you can do this:

 

Get-ADUser -SearchBase OU=OUNAME,DC=DOAMIN,DC=LOCAL' -Filter '*' | % { [color=#333333]Get-Mailbox -identity $_.Samaccountname | Set-Mailbox -HiddenFromAddressListsEnabled $true}
[/color]

Posted (edited)

I modified a powershell script to do it for disabled users if that's any help? Just needs the AD module and can be run from any server with the module (I don't have an exchange box and run this script from our file server) - whether doing it this way has any negative affect on an exchange server or not I've no idea, but I just set it for syncing to Office 365.

 

Import-Module ActiveDirectory

# Get all users in the OU.
Get-ADUser -SearchBase "OU=Intake2008OU,OU=StudentOU,DC=domain,DC=name" -Filter {(enabled -eq $false)} | Set-adUser -Replace @{msExchHideFromAddressLists="TRUE"}

Edited by Cache
Posted (edited)

I don't think you can have a Not Set for Account Enabled? The account is either enabled or disabled (so True or False)

 

Edit: If you mean does it set the value for msExchHideFromAddressLists if it's not set, then yes because non of our users have it set. Test it with one user first though in it's own OU, if it's an Onsite Exchange box I've no idea what effect it will have.

Edited by Cache

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...