Modifier

Partager via


Get-AzADServicePrincipal

Lists entities from service principals or get entity from service principals by key

Syntax

Get-AzADServicePrincipal
   [-Select <String[]>]
   [-Count]
   [-Filter <String>]
   [-Orderby <String[]>]
   [-Search <String>]
   [-ConsistencyLevel <String>]
   [-First <UInt64>]
   [-Skip <UInt64>]
   [-AppendSelected]
   [-DefaultProfile <PSObject>]
   [-CountVariable <String>]
   [<CommonParameters>]
Get-AzADServicePrincipal
   -ObjectId <String>
   [-Select <String[]>]
   [-First <UInt64>]
   [-Skip <UInt64>]
   [-AppendSelected]
   [-DefaultProfile <PSObject>]
   [<CommonParameters>]
Get-AzADServicePrincipal
   [-Select <String[]>]
   -DisplayNameBeginsWith <String>
   [-First <UInt64>]
   [-Skip <UInt64>]
   [-AppendSelected]
   [-DefaultProfile <PSObject>]
   [<CommonParameters>]
Get-AzADServicePrincipal
   [-Select <String[]>]
   -DisplayName <String>
   [-First <UInt64>]
   [-Skip <UInt64>]
   [-AppendSelected]
   [-DefaultProfile <PSObject>]
   [<CommonParameters>]
Get-AzADServicePrincipal
   [-Select <String[]>]
   -ApplicationId <Guid>
   [-First <UInt64>]
   [-Skip <UInt64>]
   [-AppendSelected]
   [-DefaultProfile <PSObject>]
   [<CommonParameters>]
Get-AzADServicePrincipal
   [-Select <String[]>]
   -ApplicationObject <IMicrosoftGraphApplication>
   [-First <UInt64>]
   [-Skip <UInt64>]
   [-AppendSelected]
   [-DefaultProfile <PSObject>]
   [<CommonParameters>]
Get-AzADServicePrincipal
   [-Select <String[]>]
   -ServicePrincipalName <String>
   [-First <UInt64>]
   [-Skip <UInt64>]
   [-AppendSelected]
   [-DefaultProfile <PSObject>]
   [<CommonParameters>]

Description

Lists entities from service principals or get entity from service principals by key

Examples

Example 1: Get service principal by display name

Get-AzADServicePrincipal -DisplayName $name

Get service principal by display name

Example 2: Search for service principal display name starts with

Get-AzADServicePrincipal -DisplayNameStartsWith $prefix

Search for service principal display name starts with

Example 3: List service principals

Get-AzADServicePrincipal -First 10 -Select Tags -AppendSelected

List first 10 service principals and append property 'Tags' after default properties: 'DisplayName', 'Id', 'DeletedDateTime', 'ServicePrincipalNames', 'AppId'

Example 4: Get service principal by application Id

Get-AzADServicePrincipal -ApplicationId $appId

Get service principal by application Id

Example 5: Get service principal by pipeline input

Get-AzADApplication -DisplayName $name | Get-AzADServicePrincipal

Get service principal by pipeline input

Example 6: Get service principal with filter

Get-AzADServicePrincipal -Filter "startsWith(DisplayName,'some-name')"

Get service principal with filter

Example 7: Assign OdataCount to a variable

Get-AzADServicePrincipal -First 10 -ConsistencyLevel eventual -Count -CountVariable 'result'
$result

Assign OdataCount to a variable

Parameters

-AppendSelected

Append properties selected with default properties when this switch is on, only works with parameter '-Select'.

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

-ApplicationId

application id of serviceprincipal

Type:Guid
Aliases:AppId
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ApplicationObject

The service principal object, could be used as pipeline input.

Type:IMicrosoftGraphApplication
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ConsistencyLevel

Indicates the requested consistency level. Documentation URL: https://developer.microsoft.com/en-us/office/blogs/microsoft-graph-advanced-queries-for-directory-objects-are-now-generally-available/

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

-Count

Include count of items

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

-CountVariable

Specifies a count of the total number of items in a collection. By default, this variable will be set in the global scope.

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

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Type:PSObject
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DisplayName

serviceprincipal display name

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-DisplayNameBeginsWith

serviceprincipal display name starts with

Type:String
Aliases:DisplayNameStartsWith, SearchString
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Filter

Filter items by property values, for more detail about filter query please see: https://learn.microsoft.com/en-us/graph/filter-query-parameter

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

-First

Gets only the first 'n' objects.

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

-ObjectId

key: id of servicePrincipal

Type:String
Aliases:ServicePrincipalId, Id
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Orderby

Order items by property values

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

Search items by search phrases

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

-Select

Select properties to be returned

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

-ServicePrincipalName

serviceprincipal name

Type:String
Aliases:SPN
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Skip

Ignores the first 'n' objects and then gets the remaining objects.

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

Inputs

IMicrosoftGraphApplication

Outputs

IMicrosoftGraphServicePrincipal