Get-MsolUser
Updated: July 30, 2015
Applies To: Azure, Office 365, Windows Intune
Note
- The cmdlets were previously known as the Microsoft Online Services Module for Windows PowerShell cmdlets.
The Get-MsolUser cmdlet can be used to retrieve an individual user, or list of users. An individual user will be retrieved if the ObjectId or UserPrincipalName parameter is used.
Syntax
Get-MsolUser [-City <string>] [-Country <string>] [-Department <string>] [-DomainName <string>] [-EnabledFilter <string>] [-HasErrorsOnly] [-LicenseReconciliationNeededOnly] [-LiveId <string>] [-MaxResults <int>] [-ReturnDeletedUsers] [-SearchString <string>] [-State <string>] [-Synchronized] [-TenantId <Guid>] [-Title <string>] [-UnlicensedUsersOnly] [-UsageLocation <string>] [<CommonParameters>]
Get-MsolUser [-All] [-City <string>] [-Country <string>] [-Department <string>] [-DomainName <string>] [-EnabledFilter <string>] [-HasErrorsOnly] [-LicenseReconciliationNeededOnly] [-ReturnDeletedUsers] [-State <string>] [-Synchronized] [-TenantId <Guid>] [-Title <string>] [-UnlicensedUsersOnly] [-UsageLocation <string>] [<CommonParameters>]
Get-MsolUser -ObjectId <Guid> [-ReturnDeletedUsers] [-TenantId <Guid>] [<CommonParameters>]
Parameters
-All [<SwitchParameter>]
If present, then all results will be returned. Cannot be used with
MaxResults parameter.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-City <string>
The city to filter results on.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Country <string>
The country to filter results on.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Department <string>
The department to filter results on.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-DomainName <string>
The domain to filter results on. This must be a verified domain for
the company. All users with an email address (primary or secondary) on
this domain will be returned.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-EnabledFilter <string>
The filter for enabled (or disabled) users. Possible values are All,
EnabledOnly, and DisabledOnly.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-HasErrorsOnly [<SwitchParameter>]
The filter for only users with validation errors.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-LicenseReconciliationNeededOnly [<SwitchParameter>]
The filter for only users that require license reconciliation.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-LiveId <string>
The user ID of the user to retrieve.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-MaxResults <int>
The maximum number of results returned for a search result. If not
specified, 500 results will be returned.
Required? false
Position? named
Default value 500
Accept pipeline input? false
Accept wildcard characters? false
-ObjectId <Guid>
The unique ID of the user to retrieve.
Required? true
Position? named
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
-ReturnDeletedUsers [<SwitchParameter>]
If set, only users in the recycle bin will be returned.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-SearchString <string>
The string to search for users. Only users with an email address or
display name starting with this string will be returned.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-State <string>
The filter for the user's state.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Synchronized [<SwitchParameter>]
The filter for only users who are synchronized through Active
Directory synchronization.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-TenantId <Guid>
The unique ID of the tenant to perform the operation on. If this is
not provided, then the value will default to the tenant of the current
user. This parameter is only applicable to partner users.
Required? false
Position? named
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
-Title <string>
The filter for the user's title.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-UnlicensedUsersOnly [<SwitchParameter>]
The filter for only users who are not assigned a license.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-UsageLocation <string>
The filter for the country where the services are consumed by the
user. This must be a two-letter country code.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-UserPrincipalName <string>
The user ID of the user to retrieve.
Required? true
Position? named
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".
Examples
The output is provided by Microsoft.Online.Administration.User. This cmdlet returns user objects, which include the following information:
AlternateEmailAddresses: Alternate email address of the user (external to ).
BlockCredential: Whether or not the user is able to sign in.
City: The user's city.
Country: The user's country.
Department: The user's department.
DisplayName: The user's display name.
Errors: An array of errors. These are validation errors that may result in loss of services.
Fax: The user's fax number.
FirstName: The user's first name.
ImmutableID: Only returned for federated users. This is the ID that is required to be federated with .
isBlackBerryUser: Returns whether or not the user has a BlackBerry device.
isLicensed: Whether or not the user has any licenses assigned.
LastDirSyncTime: The date and time of the last directory synchronization (only returned from users synced with through AD DS synchronization).
LastName: The user's last name.
LicenseReconciliationNeeded: Whether or not the user currently has a mailbox without a license. In this case, the user should be licensed with 30 days to avoid losing their mailbox.
Licenses: A list of the user's licenses.
LiveID: The user's unique login ID.
MobilePhone: The user's mobile phone number.
ObjectId: The user's unique ID.
Office: The user's office number.
OverallProvisioningStatus: Whether or not the user has been provisioned for their services.
PasswordNeverExpires: Whether the user's password should be forced to change every 90 days.
Phone Number: The user's phone number.
Postal Code: The user's postal code.
Preferred Language: The user's preferred language.
State: The user's state.
StreetAddress: The user's street address.
StrongPasswordRequired: Whether the user is required to set a strong password when they change their password. Strong passwords are recommended.
Title: The user's title.
UsageLocation: The country where the services are consumed by the user. This must be a two letter country code.
UserPrincipalName: The user ID of the user.
ValidationStatus: Whether or not the user has any errors.
Example 1
The following command retrieves all users in the company (up to 500 results).
Get-MsolUser
Example 2
The following command retrieves a list of enabled users (up to 2000 results).
Get-MsolUser -EnabledFilter EnabledOnly -MaxResults 2000
Example 3
The following command retrieves the user with the UPN johns@contoso.com
Get-MsolUser -UserPrincipalName johns@contoso.com
Example 4
The following command retrieves a user with the corresponding object ID.
Get-MsolUser -ObjectId <guid>
Example 5
The following command retrieves a list of users with "Tim" in the display name or email address (up to 500 results).
Get-MsolUser -SearchString "Tim"
Additional Resources
There are several other places you can get more information and help. These include: