Before we create a Contact object at the PowerShell command line, I would like to begin by creating a contact manually. There are two good reasons for this walk-through:
To be clear which object we are discussing.
To give us pointers for scripting, such as Alias cannot have spaces so we use an underscore in place.
PowerShell New-Mailcontact
Now we are ready to create an Exchange mail contact from the command
line. The key PowerShell verb is 'new' as in New-Mailcontact; here
are the properties we are going to script:
# Create Exchange mail contact via command-line New-Mailcontact -Name Billy Cato` -ExternalEmailAddress:
billy@guy-sport.com` -OrganizationalUnit Boston` -Alias BillyCato
Once we have created the Mail Contact here are more PowerShell
commands to configure the Contact:
Get-Mailcontact (Only contacts
that are enabled) Get-Contact (All contacts including those disabled)
Get-Mailcontact
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.
Note 2:
ExternalEmailAddress
Enable-Mailcontact
Once you have created
an Exchange 2010 contact via command line, you need to enable it. For
this you need values not only for -Identity, but also for ExternalEmailAddress. The value
for the ExternalEmailAddress can be any of these:
Guy Recommends: SolarWinds' Free Bulk Mailbox Import Tool
Import users, complete with mailbox from a spreadsheet. Just provide a list of the
users with the fields in the
top row, and save as .csv file. Then launch this FREE utility and 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.
There are also two bonus tools in the free download, and all 3 have been approved by Microsoft:
Bulk-import new users and mailboxes into Active Directory.
The purpose of this simple illustration is to list all the roles of an
Exchange Server. Observe the simplicity of PowerShell's two-part
instruction, the verb 'Get' coupled to the noun 'ExchangeServer'.
Use PowerShell's own Get-Command to extend your knowledge of Exchange
2010 contacts to list all cmdlets containing
'Exchange'.
# Research Cmdlets containing Exchange Get-Command *Exchange*
Note 5: Actually, *Exchange* doesn't
unearth many cmdlets, thus you could substitute *Mail* or *Address* in
the above example.
Discover Parameters for Your Exchange 2010 Command
Once you find a particular cmdlet that interests you, the next step is
to see if it has any useful parameters. Again use PowerShell's own
Get-Help cmdlet.
# Parameters for Exchange 2010 Commands Get-Help Get-ExchangeServer -full
Note 6: I always append -full because I like to see
Microsoft's PowerShell examples. Incidentally, this is how I knew
there was a parameter called -status.
As usual, always try the 'Get' verb, but if you know what you are doing
then experiment with: Mount,
Dismount, Clean or even Remove.
Mailbox Policy Cmdlets
You can also use PowerShell cmdlets to modify the various email policies, the key
nouns are: InboxRule and EmailAddressPolicy.
Guy
Recommends: WMI Monitor and It's Free!
Windows Management Instrumentation (WMI) is one of the hidden
treasures of Microsoft operating systems. Fortunately, SolarWinds
have created a
Free WMI Monitor so that you can discover these gems of performance
information, and thus improve your PowerShell scripts. Take the guess work out of which WMI counters to use when scripting the
operating system, Active Directory or Exchange Server.
Summary of Create Contacts with PowerShell's New-Mailcontact
It's easy to use PowerShell's New-Mailcontact to create an Exchange 2010
mail contact from the command
line. I chose creating contacts as a vehicle for PowerShell
because contacts are easier to manipulate than other Active Directory objects.
If you like this page then please share it with your friends
Windows Management Instrumentation (WMI) is one of the hidden
treasures of Microsoft operating systems.
Fortunately, SolarWinds
have created the
Free WMI Monitor so that you can actually see and understand these gems of
performance information. Take the guess work out of which
WMI counters to use for applications like Microsoft Active Directory,
SQL or Exchange Server.