Get-EntraApplication
获取应用程序。
语法
GetQuery (默认值)
Get-EntraApplication
[-Filter <String>]
[-All]
[-Top <Int32>]
[-Property <String[]>]
[<CommonParameters>]
GetByValue
Get-EntraApplication
[-SearchString <String>]
[-All]
[-Property <String[]>]
[<CommonParameters>]
GetById
Get-EntraApplication
-ApplicationId <String>
[-Property <String[]>]
[-All]
[<CommonParameters>]
说明
该 Get-EntraApplication cmdlet 获取Microsoft Entra ID应用程序。
示例
示例 1:按 ApplicationId 获取应用程序
Connect-Entra -Scopes 'Application.Read.All'
Get-EntraApplication -ApplicationId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb'
DisplayName Id AppId SignInAudience PublisherDomain
----------- -- ----- -------------- ---------------
ToGraph_443democc3c aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb bbbbbbbb-1111-2222-3333-cccccccccccc AzureADMyOrg contoso.com
此示例演示如何通过提供 ID 来检索特定应用程序。
示例 2:获取所有应用程序
Connect-Entra -Scopes 'Application.Read.All'
Get-EntraApplication -All
DisplayName Id AppId SignInAudience PublisherDomain
----------- -- ----- -------------- ---------------
test app aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb bbbbbbbb-1111-2222-3333-cccccccccccc AzureADandPersonalMicrosoftAccount contoso.com
ToGraph_443DEM cccccccc-4444-5555-6666-dddddddddddd dddddddd-5555-6666-7777-eeeeeeeeeeee AzureADMyOrg contoso.com
test adms eeeeeeee-6666-7777-8888-ffffffffffff ffffffff-7777-8888-9999-gggggggggggg AzureADandPersonalMicrosoftAccount contoso.com
test adms app azure gggggggg-8888-9999-aaaa-hhhhhhhhhhhh hhhhhhhh-9999-aaaa-bbbb-iiiiiiiiiiii AzureADandPersonalMicrosoftAccount contoso.com
test adms2 iiiiiiii-aaaa-bbbb-cccc-jjjjjjjjjjjj jjjjjjjj-bbbb-cccc-dddd-kkkkkkkkkkkk AzureADandPersonalMicrosoftAccount contoso.com
此示例演示如何从Microsoft Entra ID获取所有应用程序。
示例 3:获取没有所有者的所有应用程序(无所有者应用程序)
Connect-Entra -Scopes 'Application.Read.All'
$apps = Get-EntraApplication -All
$appsWithoutOwners = @()
foreach ($app in $apps) {
try {
$owners = Get-EntraApplicationOwner -ApplicationId $app.Id
if (-not $owners) {
$appsWithoutOwners += $app
}
}
catch {
Write-Warning "Failed to check owners for app: $($app.DisplayName)"
}
# Optional: throttle to avoid rate limits (especially in large tenants)
#Start-Sleep -Milliseconds 100
}
$appsWithoutOwners | Select-Object DisplayName, Id, AppId
DisplayName Id AppId
----------- -- -----
Contoso HR App aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb bbbbbbbb-1111-2222-3333-cccccccccccc
Contoso Helpdesk App cccccccc-4444-5555-6666-dddddddddddd dddddddd-5555-6666-7777-eeeeeeeeeeee
Contoso Helpdesk App eeeeeeee-6666-7777-8888-ffffffffffff hhhhhhhh-9999-aaaa-bbbb-iiiiiiiiiiii
此示例演示如何从Microsoft Entra ID获取不包含所有者的所有应用程序。
示例 4:在 30 天内获取具有过期机密的应用程序
$expirationThreshold = (Get-Date).AddDays(30)
$appsWithExpiringPasswords = Get-EntraApplication -All | Where-Object { $_.PasswordCredentials } |
ForEach-Object {
$app = $_
$app.PasswordCredentials | Where-Object { $_.EndDate -le $expirationThreshold } |
ForEach-Object {
[PSCustomObject]@{
DisplayName = $app.DisplayName
AppId = $app.AppId
SecretDisplayName = $_.DisplayName
KeyId = $_.KeyId
ExpiringSecret = $_.EndDate
}
}
}
$appsWithExpiringPasswords | Format-Table DisplayName, AppId, SecretDisplayName, KeyId, ExpiringSecret -AutoSize
DisplayName AppId SecretDisplayName KeyId ExpiringSecret
----------- ----- ----------------- ----- --------------
Helpdesk Application dddddddd-5555-6666-7777-eeeeeeeeeeee Helpdesk Password aaaaaaaa-0b0b-1c1c-2d2d-333333333333 11/18/2024
此示例在 30 天内检索具有过期机密的应用程序。
示例 5:在 30 天内获取具有过期证书的应用程序
$expirationThreshold = (Get-Date).AddDays(30)
$appsWithExpiringKeys = Get-EntraApplication -All | Where-Object { $_.KeyCredentials } |
ForEach-Object {
$app = $_
$app.KeyCredentials | Where-Object { $_.EndDate -le $expirationThreshold } |
ForEach-Object {
[PSCustomObject]@{
DisplayName = $app.DisplayName
AppId = $app.AppId
CertificateDisplayName = $_.DisplayName
KeyId = $_.KeyId
ExpiringKeys = $_.EndDate
}
}
}
$appsWithExpiringKeys | Format-Table DisplayName, AppId, CertificateDisplayName, KeyId, ExpiringKeys -AutoSize
DisplayName AppId CertificateDisplayName KeyId ExpiringKeys
----------- ----- ---------------------- ----- ------------
Helpdesk Application dddddddd-5555-6666-7777-eeeeeeeeeeee My cert aaaaaaaa-0b0b-1c1c-2d2d-333333333333 6/27/2024 11:49:17 AM
此示例在 30 天内检索证书过期的应用程序。
示例 6:按显示名称获取应用程序
Connect-Entra -Scopes 'Application.Read.All'
Get-EntraApplication -Filter "DisplayName eq 'ToGraph_443DEMO'"
DisplayName Id AppId SignInAudience PublisherDomain
----------- -- ----- -------------- ---------------
ToGraph_443DEMO cccccccc-4444-5555-6666-dddddddddddd dddddddd-5555-6666-7777-eeeeeeeeeeee AzureADMyOrg contoso.com
在此示例中,我们将按应用程序的显示名称从Microsoft Entra ID检索应用程序。
示例 7:在检索到的应用程序之间进行搜索
Connect-Entra -Scopes 'Application.Read.All'
Get-EntraApplication -SearchString 'My new application 2'
DisplayName Id AppId SignInAudience PublisherDomain
----------- -- ----- -------------- ---------------
My new application 2 kkkkkkkk-cccc-dddd-eeee-llllllllllll llllllll-dddd-eeee-ffff-mmmmmmmmmmmm AzureADandPersonalMicrosoftAccount contoso.com
此示例演示如何从Microsoft Entra ID检索特定字符串的应用程序。
示例 8:按 identifierUris 检索应用程序
Connect-Entra -Scopes 'Application.Read.All'
Get-EntraApplication -Filter "identifierUris/any(uri:uri eq 'https://wingtips.wingtiptoysonline.com')"
此示例演示如何通过Microsoft Entra ID的 identifierUris 检索应用程序。
示例 9:列出前 2 个应用程序
Connect-Entra -Scopes 'Application.Read.All'
Get-EntraApplication -Top 2
DisplayName Id AppId SignInAudience PublisherDomain
----------- -- ----- -------------- ---------------
test app aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb bbbbbbbb-1111-2222-3333-cccccccccccc AzureADandPersonalMicrosoftAccount contoso.com
ToGraph_443DEM cccccccc-4444-5555-6666-dddddddddddd dddddddd-5555-6666-7777-eeeeeeeeeeee AzureADMyOrg contoso.com
此示例演示如何检索两个应用程序。 您可以将 -Limit 用作 -Top 的别名。
示例 10:列出应用程序应用角色
Connect-Entra -Scopes 'Application.Read.All'
$application = Get-EntraApplication -SearchString 'Contoso Helpdesk Application'
$application.AppRoles | Format-Table -AutoSize
AllowedMemberTypes Description DisplayName Id IsEnabled Origin Value
------------------ ----------- ----------- -- --------- ------ -----
{User, Application} General All General All gggggggg-6666-7777-8888-hhhhhhhhhhhh True Application Survey.Read
{Application} General App Only General Apponly hhhhhhhh-7777-8888-9999-iiiiiiiiiiii True Application Task.Write
{User} General role General bbbbbbbb-1111-2222-3333-cccccccccccc True Application General
此示例演示如何检索应用程序的应用角色。
示例 11:列出应用程序 oauth2PermissionScopes(应用公开的委托权限)
Connect-Entra -Scopes 'Application.Read.All'
(Get-EntraApplication -Filter "displayName eq 'Contoso Helpdesk Application'").Api.Oauth2PermissionScopes
AdminConsentDescription : Allows the app to read HR data on behalf of users.
AdminConsentDisplayName : Read HR Data
Id : bbbbbbbb-1111-2222-3333-cccccccccccc
IsEnabled : True
Origin :
Type : User
UserConsentDescription : Allows the app to read your HR data.
UserConsentDisplayName : Read your HR data
Value : HR.Read.All
此示例演示如何检索 oauth2PermissionScopes (即应用公开的委托权限)到服务主体。 这些范围是应用程序对象的一部分。
示例 12:列出应用程序及其机密详细信息
Connect-Entra -Scopes 'Application.Read.All'
Get-EntraApplication -All -Property displayName, appId, passwordCredentials |
Where-Object { $_.PasswordCredentials } |
ForEach-Object {
$app = $_
foreach ($cred in $app.PasswordCredentials) {
[PSCustomObject]@{
DisplayName = $app.DisplayName
AppId = $app.AppId
PasswordCredentialsDisplayName = $cred.DisplayName
PasswordCredentialStartDate = $cred.StartDate
PasswordCredentialEndDate = $cred.EndDate
}
}
} |
Format-Table -AutoSize
DisplayName AppId PasswordCredentialsDisplayName PasswordCredentialStartDate PasswordCredentialEndDate
----------- ----- ------------------------------ --------------------------- -------------------------
Helpdesk Application gggggggg-6666-7777-8888-hhhhhhhhhhhh Helpdesk Application Password 8/20/2024 7:54:25 AM 11/18/2024 7:54:25 AM
Helpdesk Application gggggggg-6666-7777-8888-hhhhhhhhhhhh Helpdesk Application Backend 8/7/2024 4:36:49 PM 2/3/2025 4:36:49 PM
Contoso Automation App bbbbbbbb-1111-2222-3333-cccccccccccc AI automation Cred 5/3/2025 7:03:11 PM 5/3/2026 7:03:11 PM
此示例演示如何检索具有机密的应用程序。
参数
-All
列出所有页面。
参数属性
| 类型: | System.Management.Automation.SwitchParameter |
| 默认值: | False |
| 支持通配符: | False |
| 不显示: | False |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-ApplicationId
指定Microsoft Entra ID中应用程序的 ID。
参数属性
| 类型: | System.String |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
| 别名: | 对象标识符 (ObjectId) |
参数集
GetById
| Position: | Named |
| 必需: | True |
| 来自管道的值: | True |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-Filter
指定 OData v4.0 筛选器语句。 此参数控制返回的对象。
参数属性
| 类型: | System.String |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
GetQuery
| Position: | Named |
| 必需: | False |
| 来自管道的值: | True |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-Property
指定要返回的属性
参数属性
| 类型: | System.String[] |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
| 别名: | Select |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-SearchString
指定搜索字符串。
参数属性
| 类型: | System.String |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
GetVague
| Position: | Named |
| 必需: | False |
| 来自管道的值: | True |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-Top
指定要返回的最大记录数。
参数属性
| 类型: | System.Int32 |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
| 别名: | Limit |
参数集
GetQuery
| Position: | Named |
| 必需: | False |
| 来自管道的值: | True |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
CommonParameters
此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters。