Share via


Powershell script to hide user from address list

Question

Wednesday, September 30, 2015 2:16 PM

I am trying to automate the below command to read from users.csv with Identity column

Set-ADUser -Identity testuser1 -Replace @{msExchHideFromAddressLists = $true }

Users.csv looks like Below 

Identity

TestUser1

TestUser2

Below is my script:

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

$Users | ForEach-Object {

Set-ADUser -Identity $_.Identity -Replace @{msExchHideFromAddressLists = $true }
}

The command is not working. Any help?

All replies (5)

Wednesday, September 30, 2015 2:19 PM ✅Answered

Hi,

don't know whether it's the only issue, but the property-name is "msExchHideFromAddressLists", not "mxExchHideFromAddressLists".

Cheers,
Fred

There's no place like 127.0.0.1


Wednesday, September 30, 2015 2:30 PM ✅Answered

We have decommissioned exchange servers. Now we have only ADSYNC in place.

Unless you have a typo (which I doubt, as you've posted this same typo over and over again across these threads), Fred has your answer.


Wednesday, September 30, 2015 2:20 PM

Why are you trying to do this via the AD cmdlets and not via Exchange?


Wednesday, September 30, 2015 2:28 PM

We have decommissioned exchange servers. Now we have only ADSYNC in place.


Wednesday, September 30, 2015 2:45 PM

I got it to work. I love Powershell. Thanks for your help guys. You rock!!!