Author Posts

June 15, 2017 at 9:32 am

I have 940 user accounts in one OU in Active Directory Windows 2012 R2 that needs hiding from the address list. I need a script, but I am struggling. Any ideas?

June 15, 2017 at 10:38 am

Identify accounts:

get-aduser -filter {-not(msExchHideFromAddressLists -eq $true)} -searchbase "OU=xxxxxx,dc=internal,dc=xxxxx,dc=org,dc=uk" -searchscope onelevel

Apply change

| set-aduser -replace @{msExchHideFromAddressLists="TRUE"}

Resolved with some help from a friend.

June 15, 2017 at 10:38 am

Get-DistributionGroup -OrganizationalUnit " Location" | Set-DistributionGroup -HiddenFromAddressListsEnabled $TRUE

this should do the job

ohh just saw it was for users, looks like your sorted now anyway

June 15, 2017 at 10:40 am

Thank you Mark, we must have posted simultaneously : )

June 19, 2017 at 2:18 pm

| set-aduser -replace @{msExchHideFromAddressLists="TRUE"}

This does not actually hide the user in the GAL. The flag will be set, the box will be checked in Exchange, but the user is still visible. Hiding the entry also requires modification to showInAddressBook. If you don't want to use the Exchange commands, you could just clear it, but the best way is to use the appropriate Exchange command to hide it, ex: Set-Mailbox, Set-MailUser.