Get-EntraContact
Gets a contact from Microsoft Entra ID.
Syntax
GetQuery (Default)
Get-EntraContact
[-Filter <String>]
[-All]
[-Top <Int32>]
[-Property <String[]>]
[<CommonParameters>]
GetById
Get-EntraContact
-OrgContactId <String>
[-All]
[-Property <String[]>]
[<CommonParameters>]
Description
The Get-EntraContact
cmdlet gets a contact from Microsoft Entra ID.
For delegated scenarios involving work or school accounts, the signed-in user must have a supported Microsoft Entra role or a custom role with the required permissions. The following least privileged roles support this operation:
- Directory Readers: Read basic properties
- Global Reader
- Directory Writers
- Intune Administrator
- User Administrator
Examples
Example 1: Retrieve all contact objects in the directory
Connect-Entra -Scopes 'OrgContact.Read.All'
Get-EntraContact
DisplayName Id Mail MailNickname
----------- -- ---- ------------
Contoso Contact aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb contact@contoso.com Contoso Contact
Contoso Contact1 bbbbbbbb-1111-2222-3333-cccccccccccc contact1@contoso.com Contoso Contact 1
Contoso Contact2 cccccccc-2222-3333-4444-dddddddddddd contact2@contoso.com Contoso Contact 2
Contoso Contact3 dddddddd-3333-4444-5555-eeeeeeeeeeee contact3@contoso.com Contoso Contact 3
This example retrieves all contact objects in the directory.
Example 2: Retrieve specific contact object in the directory
Connect-Entra -Scopes 'OrgContact.Read.All'
$contact = Get-EntraContact -Filter "displayName eq 'Contoso Contact'"
Get-EntraContact -OrgContactId $contact.Id
DisplayName Id Mail MailNickname
----------- -- ---- ------------
Contoso Contact aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb contact@contoso.com Contoso Contact
This example retrieves specified contact in the directory.
-OrgContactId
parameter specifies the contact Id.
Example 3: Retrieve all contacts objects in the directory
Connect-Entra -Scopes 'OrgContact.Read.All'
Get-EntraContact -All
DisplayName Id Mail MailNickname
----------- -- ---- ------------
Contoso Contact aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb contact@contoso.com Contoso Contact
Contoso Contact1 bbbbbbbb-1111-2222-3333-cccccccccccc contact1@contoso.com Contoso Contact 1
Contoso Contact2 cccccccc-2222-3333-4444-dddddddddddd contact2@contoso.com Contoso Contact 2
Contoso Contact3 dddddddd-3333-4444-5555-eeeeeeeeeeee contact3@contoso.com Contoso Contact 3
This example retrieves all the contacts in the directory.
Example 4: Retrieve top two contacts objects in the directory
Connect-Entra -Scopes 'OrgContact.Read.All'
Get-EntraContact -Top 2
DisplayName Id Mail MailNickname
----------- -- ---- ------------
Contoso Contact aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb contact@contoso.com Contoso Contact
Contoso Contact1 bbbbbbbb-1111-2222-3333-cccccccccccc contact1@contoso.com Contoso Contact 1
This example retrieves top two contacts in the directory. You can use -Limit
as an alias for -Top
.
Example 5: Retrieve all contacts objects in the directory filter by DisplayName
Connect-Entra -Scopes 'OrgContact.Read.All'
Get-EntraContact -Filter "displayName eq 'Contoso Contact'"
DisplayName Id Mail MailNickname
----------- -- ---- ------------
Contoso Contact aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb contact@contoso.com Contoso Contact
Contoso Contact1 bbbbbbbb-1111-2222-3333-cccccccccccc contact1@contoso.com Contoso Contact 1
Contoso Contact2 cccccccc-2222-3333-4444-dddddddddddd contact2@contoso.com Contoso Contact 2
Contoso Contact3 dddddddd-3333-4444-5555-eeeeeeeeeeee contact3@contoso.com Contoso Contact 3
This example retrieves contacts having the specified display name.
Parameters
-All
List all pages.
Parameter properties
Type: | System.Management.Automation.SwitchParameter |
Default value: | False |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Filter
Specifies an OData v4.0 filter statement. This parameter controls which objects are returned.
Parameter properties
Type: | System.String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
GetQuery
Position: | Named |
Mandatory: | False |
Value from pipeline: | True |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-OrgContactId
Specifies the ID of a contact in Microsoft Entra ID.
Parameter properties
Type: | System.String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | ObjectId |
Parameter sets
GetById
Position: | Named |
Mandatory: | True |
Value from pipeline: | True |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-Property
Specifies properties to be returned.
Parameter properties
Type: | System.String[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | Select |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Top
Specifies the maximum number of records to return.
Parameter properties
Type: | System.Int32 |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | Limit |
Parameter sets
GetQuery
Position: | Named |
Mandatory: | False |
Value from pipeline: | True |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.