An Engineers Notebook

Working with Mail Contacts (PowerShell)

Create contacts with a CSV files

Import-CSV "C:Contacts.csv | %{New-MailContact -Name $_.Name -DisplayName %_.Name -ExternalEmailAddress $_.ExternalEmailAddress -FirstName $_.FirstName -LastName $_.LastName}

Add more information to each existing contact using a CSV file

$Contacts = Import-CSV "C:UpdateContacts.csv"

$Contacts | ForEach {Set-Contact $_.Name -StreetAddress $_.StreetAddress -City $_.City -StateorProvince $_.Stateorprovince -PostalCode $_.Postalcode -Phone $ -MobilePhone $_.Mobilephone -Pager $_.Pager -HomePhone $_.HomePhone -Company $_.Company -Title $_.title}

Hide Contacts Using Power Shell

Set-MailContact -HiddenFromAddressListsEnabled $true

OR to set ALL contacts as hidden from GAL

Get-Contact -ResultSize unlimited -Filter {(RecipientTypeDetails -eq 'MailContact')} | Set-MailContact -HiddenFromAddressListsEnabled $True

Leave a Reply

Your email address will not be published.