PowerShell Script – Exchange 2007 Mailcontact
This page explains how to create Contact and – Mailcontact objects in Exchange 2007. If you are looking for a straightforward example to learn Exchange 2007 PowerShell commands, then Mailcontact is an ideal vehicle to practise. The key verbs are: get, new and disable.
Topics for Mailcontact
- Disable Mailcontact
- Exchange PowerShell Nouns
- Exchange PowerShell Verbs
- PowerShell New-Mailcontact
To begin with, I recommend a walk-through with the Exchange Management Console. Firstly it will clarify the objects that we are creating, secondly it will alert you to nuances such as Aliases don’t have spaces.
As a prelude, open the PowerShell command prompt and type:
Get-mailcontact (Only Mail enabled objects)
Get-contact (Includes disabled contacts)
Type these commands after you have created a new mail object with the GUI, and again after you employ PowerShell to create the Mail Contact.
Note 1: As with so many PowerShell nouns contact is both case insensitive and singular.
Our mission is to achieve with PowerShell what you could do manually with the Wizard (See Right). Once you issue the plain command New-Mailcontact, you need to provide information about:
Example 1 Create a New Mailcontact called Eddie Jones”
Name: Ernie Prost
Once created you should see your new Mailcontact. Try viewing all such objects try:
Get-mailcontact | ft -autosize name, alias, ExternalEmailAddress.
Note 2: ft is an alias or shorthand for Format-Table.
Import users from a spreadsheet. Just provide a list of the users with their fields in the top row, and save as .csv file. Then launch this FREE utility and match your fields with AD’s attributes, click and import the users.
Optionally, you can provide the name of the OU where the new accounts will be born. Download your FREE bulk import tool.
If you need more comprehensive application analysis software,
Download a free trial of SAM (Server & Application Monitor)
Disabling is different from deleting the object. Disabled Mail Contacts appear in the Exchange System Manager and can be verified by comparing Get-Mailcontact with Get-Contacts. You can also confirm by checking the contents of the Disconnected folder in the Exchange Management Console.
Example 2 Disable a Mailcontact
Disable_Mailcontact ‘Eddie Jones’
Note 3: For names with spaces, enclose them with single quotes.
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.
PowerShell Scripts for the Outlook Client
It's possible to use PowerShell to read and even manipulate the Outlook Client.
Here is an example which lists the senders' email addresses in the Inbox folder.
$Folder = "InBox"
$Outlook = New-Object -ComObject Outlook.Application
$Namespace = $Outlook.GetNameSpace("MAPI")
$Email = $NameSpace.Folders.Item(1).Folders.Item($Folder).Items
$Email | Sort-Object SenderEmailAddress -Unique | FT SenderEmailAddress
Mailcontact is an Exchange object and a PowerShell noun. In order to control Mailcontact, master the verbs get, new and disable.
If you like this page then please share it with your friends
See more Microsoft PowerShell tutorials
If you see an error of any kind, do let me know. Please report any factual mistakes, grammatical errors or broken links.