当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] Set-MsolServicePrincipal - 更新服务主体的属性

作者:精品下载站 日期:2024-12-14 06:26:52 浏览:14 分类:玩电脑

Set-MsolServicePrincipal - 更新服务主体的属性


PowerShell 中的 Set-MsolServicePrincipal cmdlet 会更新 Microsoft Office 365 中的服务主体。

下面给出了更改 Microsoft Azure Active Directory 中服务主体属性的语法。

Set-MsolServicePrincipal
   [-ObjectId <Guid>]
   [-AppPrincipalId <Guid>]
   [-DisplayName <String>]
   [-ServicePrincipalNames <String[]>]
   [-AccountEnabled <Boolean>]
   [-Addresses <RedirectUri[]>]
   [-TenantId <Guid>]
   [<CommonParameters>]

在本文中,我们将讨论如何在 PowerShell 中使用 Set-MsolServicePrincipal cmdlet 更新 Azure Active Directory 中服务主体的属性。

如何更改服务主体的属性

若要更改 Office 365 中服务主体的属性,请在 PowerShell 中使用 Set-MsolServicePrincipal 命令。

# Get the service principal ID
$AppId = (Get-MsolServicePrincipal -ServicePrincipalName "ShellGeekApp/ShellApp.com").AppPrincipalId

# Update the service principal name and display name of service principal
Set-MsolServicePrincipal -AppPrincipalId $AppId -DisplayName "Shell Geek Application" -ServicePrincipalNames @("ShellGeekApp/ShellApp.com", "Shell Geek App")  

PowerShell 中的 Get-MsolServicePrincipal cmdlet 获取服务主体名称的应用程序 ID,并将其存储在 $AppId 变量中。

Set-MsolServicePrincipal 命令使用 -AppPrincipalId 参数指定应用程序 ID 并更新显示名称和服务主体名称。

此更改将覆盖 Azure Active Directory 中服务主体的先前设置。

如何更改服务主体的地址

要更改服务主体上的地址,请使用带有 -Addresses 参数的 Set-MsolServicePrincipal cmdlet。

-Addresses 参数指定要更新和覆盖现有列表的地址列表。

$AppId = (Get-MsolServicePrincipal -ServicePrincipalName "ShellGeekApp").AppPrincipalId
$a = @()
$a = $a + (Get-MsolServicePrincipal -ServicePrincipalName "ShellGeekApp").Addresses
$a = $a + (New-MsolServicePrincipalAddresses -Value "ShellApp1.com")
$a = $a + (New-MsolServicePrincipalAddresses -Value "ShellApp2.com")
Set-MsolServicePrincipal -AppPrincipalId $AppId -Addresses $a

此命令更新服务主体“ShellGeekApp”的地址。

结论

我希望上述有关如何在 PowerShell 中使用 Set-MsolServicePrincipal cmdlet 更新服务主体属性的文章对您有所帮助。

您可以在 ShellGeek 主页上找到有关 PowerShell Active Directory 命令和 PowerShell 基础知识的更多主题。

相关链接

新-MsolServicePrincipal

删除-MsolServicePrincipal

获取 MsolServicePrincipal

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯