Powershell script to hide an active directory user from the address list

Here is the command to hide an active directory user from exchange address list. The following command will hide "Spiderip" user from the global address list.

Set-ADUser spiderip -Add  {msexchhidefromaddresslists=$true} 

If you need to hide all the disabled users from the address list use the following query.

$ad_dis_users=Get-ADUser -Filter {Enabled -eq $false}

foreach ($nm in $ad_dis_users)

{

$nm1=$nm.samAccountName

Set-ADUser $nm1 -Add @{msexchhidefromaddresslists=$true} 


}

Comments