Use PowerShell to Set-Contact in Exchange 2010
Set-Contact is a nifty PowerShell cmdlet for modifying an existing Exchange contact object. If you are changing multiple contacts then you could employ a second PowerShell cmdlet such as Get-Contact; the technique is to pipe its output into Set-Contact.
- Getting Started with Set-Contact
- Example 1: Change a Contact’s Phone Number
- List the Set-Contact Parameters
- Example 2: Piping Input with Get-User
Remember that the ‘Set’ verb makes changes, thus if you it’s your first time, I recommend you check with the corresponding Get-Contact first. Another technique is to wade straight in with Set-Contact, but append the -WhatIf parameter until you are sure that the modifications are what you expected.
The only requirement with the Set-Contact cmdlet is that you supply the -Identity of the object.
Set-Contact -Identity "Guido" -MobilePhone 077 821 756
Note 1a: MobilePhone is only one of the many properties that you can amend, let us research more of Set-Contact’s parameters.
Note 1b: Other interesting parameters of the ‘Phone’ family, include Pager and HomePhone.
One of the best features of PowerShell is piping. In this instance obtain a flow of ‘Leads’ using another cmdlet, and stream them into Set-Contact so that you can adjust their ‘Department" value.
Get-User -OrganizationalUnit "Contacts" | Set-Contact -Department "Sales"
Note 2a: An alternative source cmdlet is Get-Mailbox, the piping techique would be the same as in the above script.
Import users from a spreadsheet, complete with their mailbox. Just provide a list of the users with the fields in the top row, and save as .csv file. Then launch this FREE utility, match your Exchange fields with AD’s attributes, click and import the users. Optionally, you can provide the name of the OU where the new mailboxes will be born.
- Bulk-import new users and mailboxes into Active Directory.
- Seek and zap unwanted user accounts.
- Find inactive computers.
Compare PowerShell with the EMC
- Launch the EMC, navigate to the Recipient Configuration, Mail Contact (see screenshot right)
It’s also possible to create new contacts.
# Create a Contact with PowerShell
New-Mailcontact -Name Guido Smith `
-ExternalEmailAddress: Guido@guy-sport.com `
If you created a Mail Contact manually, then Get-mailcontact should display the name, both objects.
Get-mailcontact | Format-Table name, alias, ExternalEmailAddress -autosize.
Note 1: In PowerShell nouns are singular.
In order to disable a mailcontact you need its Alias or DN. For example
Disable-Mailcontact Martha Jones
Note disable is different from delete. If you wished to delete a mailcontact then the command is:
Remove-Mailcontact Martha Jones
Here is a free tool to monitor your Exchange Server. Download and install the utility, then inspect your mail queues, monitor the Exchange server’s memory, confirm there is enough disk space, and check the CPU utilization.
This is the real deal – there is no catch. SolarWinds provides this fully-functioning freebie, as part of their commitment to supporting the network management community.
Summary of Create Contacts with PowerShell
Set-Contact is a nifty PowerShell cmdlet for changing a property on existing Exchange contact object, for example, MobilePhone, City or Company.
If you like this page then please share it with your friends