When I run az ad sp list
, I get a list of service principals which includes an accountEnabled
attribute:
I adjusted the command to show only the ones that are enabled using this command:
az ad sp list | where-object { $_.AccountEnabled -eq 'true' }
However, when I do, I get no results. What's the correct method for listing the active Service Principals?
To list the service principal based on
accountEnabled = true
using Azure CLI
When I ran, the command mentioned by you, I got following response:
az ad sp list | where-object { $_.AccountEnabled -eq 'true' }
Response:
To resolve the error use this modified command:
az ad sp list --filter "accountEnabled eq true" --output json
Response:
To list the service principal with accountEnabled = true
using PowerShell, use this:
Get-AzADServicePrincipal
| Where-Object { $_.AccountEnabled -eq $true }
| Select-Object DisplayName, AppId, AccountEnabled
Response:
References: