Get-PnPAADUser

Tip

We encourage you to make improvements to this documentation. Please navigate to https://github.com/pnp/powershell/blob/dev/documentation/Get-PnPAADUser.md to change this file.

Required Permissions

  • Microsoft Graph API : One of Directory.Read.All, Directory.ReadWrite.All, User.Read.All, User.ReadWrite.All

Retrieves users from Azure Active Directory. By default the following properties will be loaded: BusinessPhones, DisplayName, GivenName, JobTitle, Mail, MobilePhone, OfficeLocation, PreferredLanguage, Surname, UserPrincipalName, Id, AccountEnabled

Syntax

Get-PnPAADUser
   [-Filter <String>]
   [-OrderBy <String>]
   [-Select <String[]>]
   [-StartIndex <Int32>]
   [-EndIndex<Int32>]
   [<CommonParameters>]
Get-PnPAADUser
   [-Identity <String>]
   [-Select <String[]>]
   [<CommonParameters>]
Get-PnPAADUser
   [-Filter <String>]
   [-OrderBy <String>]
   [-Select <String[]>]
   [-Delta]
   [-DeltaToken <String>]
   [-StartIndex <Int32>]
   [-EndIndex<Int32>]
   [<CommonParameters>]

Examples

EXAMPLE 1

Get-PnPAADUser

Retrieves the first 1000 users from Azure Active Directory

EXAMPLE 2

Get-PnPAADUser -EndIndex $null

Retrieves all users from Azure Active Directory

EXAMPLE 3

Get-PnPAADUser -Identity 328c7693-5524-44ac-a946-73e02d6b0f98

Retrieves the user from Azure Active Directory with the id 328c7693-5524-44ac-a946-73e02d6b0f98

EXAMPLE 4

Get-PnPAADUser -Identity john@contoso.com

Retrieves the user from Azure Active Directory with the user principal name john@contoso.com

EXAMPLE 5

Get-PnPAADUser -Identity john@contoso.com -Select "DisplayName","extension_3721d05137db455ad81aa442e3c2d4f9_extensionAttribute1"

Retrieves only the DisplayName and extensionAttribute1 properties of the user from Azure Active Directory which has the user principal name john@contoso.com

EXAMPLE 6

Get-PnPAADUser -Filter "accountEnabled eq false"

Retrieves all the disabled users from Azure Active Directory

EXAMPLE 7

Get-PnPAADUser -Filter "startswith(DisplayName, 'John')" -OrderBy "DisplayName"

Retrieves all the users from Azure Active Directory of which their DisplayName starts with 'John' and sort the results by the DisplayName

EXAMPLE 8

Get-PnPAADUser -Delta

Retrieves all the users from Azure Active Directory and include a delta DeltaToken which can be used by providing -DeltaToken to query for changes to users in Active Directory since this run

EXAMPLE 9

Get-PnPAADUser -Delta -DeltaToken abcdef

Retrieves all the users from Azure Active Directory which have had changes since the provided DeltaToken was given out

EXAMPLE 10

Get-PnPAADUser -StartIndex 10 -EndIndex 20

Retrieves the 10th through the 20th user from Azure Active Directory

Parameters

-Delta

Retrieves all users and provides a SkipToken delta token to allow to query for changes since this run when querying again by adding -DeltaToken to the command

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-DeltaToken

The change token provided during the previous run with -Delta to query for the changes to user objects made in Azure Active Directory since that run

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-EndIndex

Allows defining the last result to return. Useful for i.e. pagina. If omitted, it will use 999. If set to $null, it will return all users from Azure Active Directory.

Type:Int32
Position:Named
Default value:999
Accept pipeline input:False
Accept wildcard characters:False
-Filter

Includes a filter to the retrieval of the users. Use OData instructions to construct the filter, i.e. "startswith(DisplayName, 'John')".

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Identity

Returns the user with the provided user id

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-OrderBy

Includes a custom sorting instruction to the retrieval of the users. Use OData syntax to construct the orderby, i.e. "DisplayName desc".

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Select

Allows providing an array with the property names of specific properties to return. If not provided, the default properties will be returned.

Type:String[]
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-StartIndex

Allows defining the first result to return. Useful for i.e. paging.

Type:Int32
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False