Get-MsolServicePrincipal
Gets service principals from Azure Active Directory.
Syntax
Get-MsolServicePrincipal
[-SearchString <String>]
[-MaxResults <Int32>]
[-TenantId <Guid>]
[<CommonParameters>]
Get-MsolServicePrincipal
-ObjectId <Guid>
[-TenantId <Guid>]
[<CommonParameters>]
Get-MsolServicePrincipal
-AppPrincipalId <Guid>
[-TenantId <Guid>]
[<CommonParameters>]
Get-MsolServicePrincipal
-ServicePrincipalName <String>
[-TenantId <Guid>]
[<CommonParameters>]
Get-MsolServicePrincipal
[-SearchString <String>]
[-All]
[-TenantId <Guid>]
[<CommonParameters>]
Description
The Get-MsolServicePrincipal cmdlet gets a service principal or a list of service principals from Azure Active Directory.
Examples
Example 1: Display all service principals
PS C:\> Get-MsolServicePrincipal
This command displays all the existing service principals in the organization's tenant.
Example 2: Get service principals by using a name
PS C:\> Get-MsolServicePrincipal -ServicePrincipalName "MyApp"
This command gets all the existing service principals that have a service principal name that starts with MyApp. This is an exact match of the appClass portion of the service principal name up to the forward slash.
Example 3: Get a service principal
PS C:\> Get-MsolServicePrincipal -AppPrincipalId 5e964d2f-e384-4292-ae55-dd24c89cc53b
This command gets a service principal that has a specific application principal ID.
Parameters
-All
Indicates that this cmdlet returns all results. Do not specify together with the MaxResults parameter.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-AppPrincipalId
Specifies the unique application ID of the service principal to get.
Type: | Guid |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-MaxResults
Specifies the maximum number of results that this cmdlet returns. The default value is 500.
Type: | Int32 |
Position: | Named |
Default value: | 500 |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ObjectId
Specifies the unique object ID of the service principal to get.
Type: | Guid |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-SearchString
Specifies a string to match service principal names.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ServicePrincipalName
Specifies the name of the service principal or service principals to get. An SPN must use one of the following formats:
appName
appName/hostname
- a valid URL
AppName represents the name of the application and hostname represents the URI authority for the application.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-TenantId
Specifies the unique ID of the tenant on which to perform the operation. The default value is the tenant of the current user. This parameter applies only to partner users.
Type: | Guid |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Outputs
Microsoft.Online.Administration.ServicePrincipal[]
This cmdlet returns a service principal or a list of service principals from Azure Active Directory. Each service principal contains the following information:
- ObjectId. The unique identifier of the service principal.
- AppPrincipalId. The application identifier of the service principal.
- DisplayName. The friendly name of the service principal.
- ServicePrincipalName. The list of service principal names (SPNs) associated with the service principal.
- AccountEnabled. The value indicating if the account is enabled.