5.2. Using the EMS to Manage User Properties
You can also manage mailbox and user
properties from the EMS. For doing any type of mailbox administration
"in bulk," you will definitely want to learn how to use the EMS. There
are three cmdlets that you should know about in order to manage most of
the properties: the Set-User, Set-Mailbox, and Set-CasMailbox cmdlets.
Let's start with the Set-User cmdlet; this
cmdlet manages user account properties that are unrelated to Exchange
Server. Say that we want to update user Stan.Reimer's mobile phone
number. We would type this:
Set-User Stan.Reimer -MobilePhone "(808) 555-1234"
The Set-User cmdlet has quite a few useful parameters. Table 3 lists many of these options. You can retrieve them from within the EMS by typing Set-User -? or Help Set-User.
Table 3. Some Set-User Cmdlet Parameters
Parameter | Function |
---|
PostalCode | Sets the zip or postal code. |
Manager | Sets the name of the user's manager; the input value must be a distinguished name in canonical name format, such as fourthcoffee.com/Corporate/Ben Craig. |
DisplayName | Updates the user's display name, which appears in the GAL. |
MobilePhone | Sets the mobile/cell phone number. |
City | Sets the city or locality name. |
FirstName | Specifies the given or first name. |
LastName | Specifies the surname or last name. |
Company | Sets the company name. |
Department | Sets the department name. |
Fax | Specifies the facsimile number. |
HomePhone | Sets the home phone number. |
Phone | Sets the business phone number. |
StateOrProvince | Sets the state or province. |
StreetAddress | Sets the street address. |
Title | Sets the title or job function. |
You can retrieve the list of properties for Set-User by using the Get-User cmdlet, specifying a username, and then piping the output to the Format-List cmdlet. Piping the output of a Get- cmdlet to Format-List
is a great way to enumerate of the properties of an object and to also
learn the property names. Here is an example of some of the properties
that are returned; we removed some properties to save space.
Get-User Matthew.Cook | FL
IsSecurityPrincipal : True
SamAccountName : Matthew.Cook
SidHistory : {}
UserPrincipalName : Matthew.Cook@ithicos.local
ResetPasswordOnNextLogon : False
CertificateSubject : {}
RemotePowerShellEnabled : True
NetID :
OrganizationalUnit : ithicos.local/Corporate
AssistantName :
City : Honolulu
Company : Somorita Surfboards
CountryOrRegion :
Department : Surfboard Design
DirectReports : {}
DisplayName : Matthew Cook
Fax : (808) 555-6657
FirstName : Matthew
HomePhone :
Initials :
LastName : Cook
Manager :
MobilePhone : (808) 555-7777
Notes :
Office : Honolulu Surfboard Design
OtherFax : {}
OtherHomePhone : {}
OtherTelephone : {}
Pager : (808) 555-5545
Phone : (808) 555-1234
PhoneticDisplayName :
PostalCode : 96816
PostOfficeBox : {}
RecipientType : UserMailbox
RecipientTypeDetails : UserMailbox
SimpleDisplayName : Matt Cook (Honolulu)
StateOrProvince : Hawaii
StreetAddress : 550 Kalakaua Avenue, Suite 201
Title : Senior Systems Engineer
UMDialPlan :
UMDtmfMap : {emailAddress:62884392665,
lastNameFirstName:26656288439, firstNameLastName:62884392665}
AllowUMCallsFromNonUsers : SearchEnabled
WebPage :
TelephoneAssistant :
WindowsEmailAddress : MatthewCook@ithicos.local
UMCallingLineIds : {}
IsValid : True
ExchangeVersion : 0.10 (14.0.100.0)
Name : Matthew Cook
DistinguishedName : CN=Matthew Cook,OU=Corporate,
DC=ithicos,DC=local
OriginatingServer : HNLMBX01.ithicos.local
Not only does the Get-User cmdlet allow you
to view this information about a user account, but it also allows you
to see all the property names. For example, if you did not know what
the property name was for the State, you could look in the output
listing and see that it is -StateOrProvince. You could then change the user's state by typing the following EMS command:
Set-User vlad.mazek -StateOrProvince "Florida"
You can pipe the output of one cmdlet together with
another one in order to perform bulk administration. Let's say that we
want to set the Office name of all users who are in Honolulu. We can
use a combination of Get-User and Set-User to accomplish this:
Get-User | Where-Object {$_.city -eq "Honolulu"} |
Set-User -Office "Main Office"
In this example, we piped the output of the Get-User cmdlet to a local filter (using the Where-Object cmdlet). This provided us with a subset of only the users whose city property is equal to Honolulu; the output of that was then piped to the Set-User cmdlet and the office property was updated. That was not too difficult once you saw it the first time, was it?