View the service principal of a managed identity using PowerShell
Managed identities for Azure resources provides Azure services with an automatically managed identity in Microsoft Entra ID. You can use this identity to authenticate to any service that supports Microsoft Entra authentication, without having credentials in your code.
In this article, you learn how to view the service principal of a managed identity using PowerShell.
Note
We recommend that you use the Azure Az PowerShell module to interact with Azure. See Install Azure PowerShell to get started. To learn how to migrate to the Az PowerShell module, see Migrate Azure PowerShell from AzureRM to Az.
Prerequisites
- If you're unfamiliar with managed identities for Azure resources, check out the overview section.
- If you don't already have an Azure account, sign up for a free account.
- Enable system assigned identity on a virtual machine or application.
- To run the example scripts, you have two options:
- Use the Azure Cloud Shell, which you can open using the Try It button on the top right corner of code blocks.
- Run scripts locally by installing the latest version of Azure PowerShell, then sign in to Azure using
Connect-AzAccount
.
View the service principal
This following command demonstrates how to view the service principal of a VM or application with system assigned identity enabled. Replace <Azure resource name>
with your own values.
Get-AzADServicePrincipal -DisplayName <Azure resource name>
Next steps
For more information on viewing Microsoft Entra service principals using PowerShell, see Get-AzADServicePrincipal.
Feedback
Submit and view feedback for