From: Karl Mitschke on
Hello Jeff,

> Karl,
> Thanks for your reply. I tried just using get-mailcontact and the
> syntax you provide works. However(and this is what I find puzzling),
> when I use get-mailcontact like you suggest, it doesn't error out, but
> I also don't get any results back. However, replacing get-mailcontact
> with get-user gives me all of the entries I'm trying to find.
> Thanks,
> Jeff
> On Apr 1, 12:51 pm, Karl Mitschke <karlmitsc...(a)> wrote:
>> Hello Jeff,
>>> I'm trying to get the check box that says "Hide From Exchange
>>> Address Lists" checked for about 900 mail contacts in our exchange
>>> 2007 system. To select the users, I enter this into powershell:
>>> get-user -filter {WindowsEmailAddress -eq ''}
>>> When I do that, it pulls every user that I am interested in.
>>> However, when I try to pipe that into get-mailcontact, I get an
>>> error that says the user that was piped in can't be found on the
>>> domain controller. I've tried forcing it to different domain
>>> controllers and always get the same result.
>>> Any suggestions for getting around this?
>>> Thanks.
>> Why not use Get-MailContact?
>> Get-MailContact -filter {WindowsEmailAddress -eq
>> ''} |Set-MailContact -HiddenFromAddressListsEnabled:
>> $True -whatif
>> Karl


Do this:
get-user -filter {WindowsEmailAddress -eq ''} |Select-Object
Name, RecipientType

Are they really of type MailContact?

If so, Get-MailContact -filter {WindowsEmailAddress -eq ''}
should have found them, as you've proven they have a WindowsEmailAddress.

However, a MailContact should not be a user type, so I have the feeling all
you will return are MailUsers and perhaps UserMailboxes using Get-User.

On the off chance that the get-user returns the contacts you are intetrestred
in, try this:

Get-User -filter {WindowsEmailAddress -eq ''} | ForEach-Object
{Set-MailContact -Identity $_Alias -HiddenFromAddressListsEnabled: $True

Assuming the Get-User returns invalid data, try this:

Get-MailContact -filter {PrimarySmtpAddress -eq ''} |Set-MailContact
-HiddenFromAddressListsEnabled: $True -whatif
(Thanks, Rich)