MrFrostmaul Posted September 13, 2015 Posted September 13, 2015 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
howartp Posted September 13, 2015 Posted September 13, 2015 Powershell this should be a couple of lines. I'll try look tomorrow.
craigw Posted September 14, 2015 Posted September 14, 2015 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.
3s-gtech Posted September 14, 2015 Posted September 14, 2015 ADModify.NET is ideal for this. Needs .NET 2.0 to run (the installer needs 1.1 but you can just run the extracted files without installing).
jdell Posted September 14, 2015 Posted September 14, 2015 (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 September 14, 2015 by jdell
halbaradkenafin Posted September 14, 2015 Posted September 14, 2015 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]
Cache Posted September 14, 2015 Posted September 14, 2015 (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 September 14, 2015 by Cache
MrFrostmaul Posted September 14, 2015 Author Posted September 14, 2015 Thanks Cache and from everyone - Does the Filter for enabled false work if the default vault is Not set ? Thanks
Cache Posted September 14, 2015 Posted September 14, 2015 (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 September 14, 2015 by Cache
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now