- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试通过以下 PowerShell 命令重置服务主体(我们称之为 SP1)的密码凭据:
Remove-AzADSpCredential -ObjectId <SP1_objectId> -Force
$Password = New-AzADSpCredential -ObjectId <SP1_objectId>
当我通过自己的用户帐户(该帐户已分配给 SP1 的所有者角色)通过 PowerShell 运行它时,效果很好。
我还在具有“运行帐户”服务主体(我们称之为 SP2)的自动化帐户的 Runbook 中包含此代码。
我还通过命令 Add-AzureADServicePrincipalOwner
将 SP1 的所有权分配给 SP2,并通过 Get-AzureADServicePrincipalOwner
确认。
我希望 Runbook 在将其服务主体设为 SP1 的所有者后能够在 SP1 上运行 Remove-AzADSpCredential
命令。但我收到以下错误:
Remove-AzADSpCredential : Insufficient privileges to complete the operation. At line:43 char:9 + Remove-AzADSpCredential -ObjectId $key.Name -Force + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Remove-AzADSpCredential], Exception + FullyQualifiedErrorId : Microsoft.Azure.Commands.ActiveDirectory.RemoveAzureADSpCredentialCommand
New-AzADSpCredential
命令也出现同样的错误。
我认为也许 SP1 的所有权应该分配给运行帐户的应用程序,而不是其服务主体。
所以我还运行了以下命令:
Add-AzureADServicePrincipalOwner -ObjectId <SP1_ObjectId> -RefObjectId <runasaccount_app_ObjectId>
但这不可能,因为我收到了错误:
Code: Request_BadRequestMessage: The reference target 'Application_xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx' of type 'Application' is invalid for the 'owners' reference.
所以我认为所有权应该只分配给 SP2,而不是应用程序。
我查看了here但接受的答案说
If your user accounts are the Owner of the service principal(Enterprise application), the command New-AzADSpCredential will work.
这对我来说是正确的,但是在运行 Runbook 时它不起作用。
我还查看了here看来我需要做OP描述的很容易做的#1。
任何有关如何执行此操作的意见将不胜感激。
最佳答案
如果您想使用一个服务主体添加/删除另一个服务主体的凭据,这与使用用户帐户执行此操作不同。
I assigned the ownership of SP1 to SP2 as well through the command
Add-AzureADServicePrincipalOwner
and confirmed it throughGet-AzureADServicePrincipalOwner
.
这种方式是正确的,但不仅仅是Owner
,您还需要给出 Application.ReadWrite.OwnedBy
Azure Active Directory Graph
中的应用程序权限 (不是 Microsoft Graph
)之后的 API。
导航至API permissions
您的自动化帐户对应门户中的AD应用程序 ->添加如下所示的权限,不要忘记单击Grant admin consent for xxx
最后按钮。
然后在runbook中测试一下,效果很好。
New-AzADSpCredential -ObjectId xxxxxxxxxxxxx
Owner
的组合和Application.ReadWrite.OwnedBy
本例中是最低权限,还有其他方式,也可以给Application Administrator
如您所见的目录角色 here或Application.ReadWrite.All
Azure Active Directory Graph
中的应用程序权限 ,两者都可以。
关于azure - 如何使用自动化帐户 PowerShell Runbook 重置 Azure 服务主体的凭据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66324109/
我有一个配置了混合 Runbook Worker 的自动化帐户,突然所有作业每 15 分钟就会重新启动 3 次,并最终因错误而暂停: 工作被暂停。要进行其他故障排除,请检查混合 Runbook 工作组
我有一个运行手册名称“RB_ConnectSQL” workflow RB_ConnectSQL { [OutputType([string])] param (
我对 Azure Runbook 和自动化还很陌生。 我有几个azure Sql 数据库,并且数据库中有我想按顺序运行的存储过程。在使用 On-premises SQL Server 之前,我们有一个
场景: 我有 2 个 Runbook,Runbook A 和 Runbook B。 在 Runbook B 中,我想将 Runbook A 加载到内存中。 以下运行不起作用,有人可以帮我吗? .\ru
背景 我有一个 Azure Runbook(名为 RunStoredProcedure2),定义如下: param( [parameter(Mandatory=$True)] [string] $Sq
我想使用 Runbook 删除另一个 Runbook 输出(Azure 文件共享快照)。 这可能吗?如果您知道什么,请在这里写下 运行手册 1:创建 Azure 文件共享快照 $context = N
背景: 我正在尝试通过 Azure 上的 Runbook 设置脚本。我发现不寻常的是,我可以通过 Azure Powershell Cloud Shell 运行该命令并且它可以工作。但是,当我尝试通过
我有一个每天早上运行的 Azure Runbook。 Runbook 执行“Get-AzureStorageBlob”,但由于我们在存储帐户上启用了防火墙,它现在失败并出现错误: Get-AzureS
所以我有一个运行手册,可以在周末自动关闭和启动我的 Azure VM。然后发送一封事务电子邮件,确认 VPS 已关闭/启动。 我已经如图所示设置了参数。是否有原因说明为什么它在主题行中正确说明了我的虚
我有一个处于运行状态的 PowerShell Azure Runbook。 通过 Azure 门户按“停止”会导致错误消息: "Job could not be stopped". 使用 PowerS
我在自动化帐户中使用 Azure Runbook 已经有一段时间了,但最近我的任务是确定谁在执行该 Runbook。 我注意到当您从作业中获取信息时,有一个名为“执行者”的字段,但似乎该字段已被 MS
我正在尝试设置 Powershell Runbook 来访问 Azure 资源。 我正在按照 this page 上的说明进行操作. 我已为自动化帐户分配了系统身份,但示例脚本根本不起作用。 # Si
我正在尝试设置 Powershell Runbook 来访问 Azure 资源。 我正在按照 this page 上的说明进行操作. 我已为自动化帐户分配了系统身份,但示例脚本根本不起作用。 # Si
我的自动化帐户中有一个 Azure PowerShell 7.1 Runbook,它正在按预期执行。我遇到的唯一问题是运行作业屏幕中的错误输出始终缺少详细信息列。这意味着我必须点击每条记录才能查看其中
我正在尝试运行 API 管理服务的备份。我可以在我的本地计算机上使用下面的代码在我的子所有者登录上下文中在 PS 中执行此操作,不会出现任何问题。 当我尝试将其作为 Runbook 运行时,我只会返回
我有一个 Runbook PowerShell,它会删除所有资源组及其上的所有内容,但带有 RG 的名称。有没有办法做同样的事情,但只能使用与该 RG 关联的标签?运行 Runbook 时,它不会要求
Azure 运行手册。 问题: 如何通过 Runbook 在远程 Azure VM 上运行/调用 powershell 脚本?该脚本放置在远程虚拟机上。 没有 Azure AD,powershell
我创建了一个 Runbook 来处理多维数据集的多个分区。我启动了它,3小时后,它停止了。没有错误消息或警告,输出 Pane 中也没有任何内容。我唯一的消息就是这个 异常 该作业被逐出并随后达到停止状
我无法在 Azure Runbook 中运行“Get-Azurermlog”。我收到错误“术语“Get-Azurermlog”未被识别为 cmdlet、函数、脚本文件或可操作程序的名称”。它是一个标准
我一直在到处寻找,但我什至找不到一个简单的方法来使用 powershell 列出 Runbook...我有 4 个订阅,每个订阅中有几个自动化帐户,当我试图通过控制台浏览来查找特定的 Runbook
我是一名优秀的程序员,十分优秀!