Set-EntraServicePrincipal

更新服务主体。

语法

Default (默认值)

Set-EntraServicePrincipal

    -ServicePrincipalId <String>
    [-KeyCredentials <System.Collections.Generic.List`1[Microsoft.Open.AzureAD.Model.KeyCredential]>]
    [-Homepage <String>]
    [-AppId <String>]
    [-LogoutUrl <String>]
    [-ServicePrincipalType <String>]
    [-AlternativeNames <System.Collections.Generic.List`1[System.String]>]
    [-PasswordCredentials <System.Collections.Generic.List`1[Microsoft.Open.AzureAD.Model.PasswordCredential]>]
    [-PreferredSingleSignOnMode <String>]
    [-Tags <System.Collections.Generic.List`1[System.String]>]
    [-AccountEnabled <String>]
    [-ServicePrincipalNames <System.Collections.Generic.List`1[System.String]>]
    [-AppRoleAssignmentRequired <Boolean>]
    [-DisplayName <String>]
    [-ReplyUrls <System.Collections.Generic.List`1[System.String]>]
    [<CommonParameters>]

说明

该 cmdlet 更新Set-EntraServicePrincipalMicrosoft Entra ID中的服务主体。

示例

示例 1:禁用服务主体的帐户

Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy'
$servicePrincipal = Get-EntraServicePrincipal -Filter "displayName eq 'Helpdesk Application'"
Set-EntraServicePrincipal -ServicePrincipalId $servicePrincipal.Id -AccountEnabled $false

此示例演示如何更新AccountEnabledMicrosoft Entra ID中的服务主体。

  • -ServicePrincipalId 参数指定服务主体的 ID。
  • -AccountEnabled 参数指定指示是否启用帐户。

示例 2:更新服务主体的主页

Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy'
$servicePrincipal = Get-EntraServicePrincipal -Filter "displayName eq 'Helpdesk Application'"
$homePage = 'https://*.e-days.com/SSO/SAML2/SP/AssertionConsumer.aspx?metadata=e-days|ISV9.2|primary|z'
Set-EntraServicePrincipal -ServicePrincipalId $servicePrincipal.Id -Homepage $homePage

此示例演示如何在 Microsoft Entra ID 中更新AppId和主页服务主体。

  • -ServicePrincipalId 参数指定服务主体的 ID。
  • -AppId 参数指定应用程序 ID。
  • -Homepage 参数指定应用程序的主页或登陆页。

示例 3:更新服务主体的 AlternativeNames 和 DisplayName

Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy'
$servicePrincipal = Get-EntraServicePrincipal -Filter "displayName eq 'Helpdesk Application'"
Set-EntraServicePrincipal -ServicePrincipalId $servicePrincipal.Id -AlternativeNames 'Helpdesk Application Global' -DisplayName 'NewName'

此示例演示如何在 Microsoft Entra ID 中更新服务主体的 AlternativeNames 和 DisplayName。

  • -ServicePrincipalId 参数指定服务主体的 ID。

示例 4:更新服务主体的 LogoutUrl 和 ReplyUrl

Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy'
$servicePrincipal = Get-EntraServicePrincipal -Filter "displayName eq 'Helpdesk Application'"
$logoutUrl = 'https://securescore.office.com/SignOut'
$replyUrls = 'https://admin.contoso.com'
Set-EntraServicePrincipal -ServicePrincipalId $servicePrincipal.Id -LogoutUrl $logoutUrl -ReplyUrls $replyUrls

此示例演示如何在 Microsoft Entra ID 中更新服务主体的 LogoutUrl 和 ReplyUrl。

  • -ServicePrincipalId 参数指定服务主体的 ID。
  • -LogoutUrl 参数指定注销 URL。
  • -ReplyUrls 参数指定用户令牌发送到的 URL,以便与关联的应用程序登录。

示例 5:更新服务主体的 ServicePrincipalType 和 AppRoleAssignmentRequired

Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy'
$servicePrincipal = Get-EntraServicePrincipal -Filter "displayName eq 'Helpdesk Application'"
Set-EntraServicePrincipal -ServicePrincipalId $servicePrincipal.Id -ServicePrincipalType 'Application' -AppRoleAssignmentRequired $True

此示例演示如何在Microsoft Entra ID中更新ServicePrincipalType和AppRoleAssignmentRequired服务主体。

  • -ServicePrincipalId 参数指定服务主体的 ID。
  • -ServicePrincipalType 参数指定服务主体类型。
  • -AppRoleAssignmentRequired 参数指定指示是否需要应用程序角色分配。

示例 6:更新服务主体的 KeyCredentials

Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy'
$servicePrincipal = Get-EntraServicePrincipal -Filter "displayName eq 'Helpdesk Application'"
$creds = New-Object Microsoft.Open.AzureAD.Model.KeyCredential
$creds.CustomKeyIdentifier = [System.Text.Encoding]::UTF8.GetBytes('Test')
$startdate = Get-Date -Year 2024 -Month 10 -Day 10
$creds.StartDate = $startdate
$creds.Type = 'Symmetric'
$creds.Usage = 'Sign'
$creds.Value = [System.Text.Encoding]::UTF8.GetBytes('A')
$creds.EndDate = Get-Date -Year 2025 -Month 12 -Day 20
Set-EntraServicePrincipal -ServicePrincipalId $servicePrincipal.Id -KeyCredentials $creds

此示例演示如何在 Microsoft Entra ID 中更新服务主体的 KeyCredentials。

New-EntraServicePrincipalPasswordCredential使用和 Remove-EntraServicePrincipalPasswordCredential cmdlet 更新 servicePrincipal 的密码或机密。

示例 7:更新服务主体的 PreferredSingleSignOnMode

Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy'
$servicePrincipal = Get-EntraServicePrincipal -Filter "displayName eq 'Helpdesk Application'"
Set-EntraServicePrincipal -ServicePrincipalId $servicePrincipal.Id -PreferredSingleSignOnMode 'saml'

此示例演示如何更新PreferredSingleSignOnModeMicrosoft Entra ID中的服务主体。

  • -ServicePrincipalId 参数指定服务主体的 ID。
  • -PreferredSingleSignOnMode 参数指定为此应用程序配置的单一登录模式。

参数

-AccountEnabled

指示是否启用帐户。

参数属性

类型:System.String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-AlternativeNames

此服务主体的替代名称。

参数属性

类型:

System.Collections.Generic.List`1[System.String]

默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-AppId

指定应用程序 ID。

参数属性

类型:System.String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-AppRoleAssignmentRequired

指示是否需要分配应用程序角色。

参数属性

类型:System.Boolean
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-DisplayName

指定显示名称。

参数属性

类型:System.String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Homepage

指定应用程序的主页或登陆页。

参数属性

类型:System.String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-KeyCredentials

指定密钥凭据。

参数属性

类型:

System.Collections.Generic.List`1[Microsoft.Open.AzureAD.Model.KeyCredential]

默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-LogoutUrl

指定注销 URL。

参数属性

类型:System.String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-PasswordCredentials

指定密码凭据。

参数属性

类型:

System.Collections.Generic.List`1[Microsoft.Open.AzureAD.Model.PasswordCredential]

默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-PreferredSingleSignOnMode

指定为此应用程序配置的单一登录模式。 Microsoft Entra ID使用首选的单一登录模式从 Microsoft 365 或 我的应用 门户启动应用程序。 支持的值包括密码、saml、notSupported 和 oidc。

参数属性

类型:System.String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-ReplyUrls

用户令牌发送到的 URL 用于与关联的应用程序登录,或将 OAuth 2.0 授权代码和访问令牌发送到的重定向统一资源标识符,以供关联应用程序使用。

参数属性

类型:

System.Collections.Generic.List`1[System.String]

默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-ServicePrincipalId

Microsoft Entra ID中服务主体的 ID。

参数属性

类型:System.String
默认值:None
支持通配符:False
不显示:False
别名:对象标识符 (ObjectId)

参数集

(All)
Position:Named
必需:True
来自管道的值:True
来自管道的值(按属性名称):True
来自剩余参数的值:False

-ServicePrincipalNames

指定服务主体名称。

参数属性

类型:

System.Collections.Generic.List`1[System.String]

默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-ServicePrincipalType

服务主体类型。

参数属性

类型:System.String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Tags

指定一个标签数组。

如果希望此服务主体显示在管理门户中的“所有应用程序”列表中,则需要将此值设置为 {WindowsAzureActiveDirectoryIntegratedApp}。

参数属性

类型:

System.Collections.Generic.List`1[System.String]

默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

CommonParameters

此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters。