使用PowerShell获取Azure自动化帐户连接的服务主体

我知道在自动化帐户中运行Runbook时如何在内部使用Get-Automationaccount来检索连接详细信息。

但是,如果我想报告运行手册作业外部的AzureRunAsConnection使用的服务主体怎么办?

我已经尝试过以下操作:

$automationaccount = Get-AzAutomationaccount -ResourceGroupName $rg -Name $name
$conn = $automationaccount | Get-AzAutomationConnection
$conn.FieldDefinitionValues

但是,FielDefinitionValues哈希表中没有任何内容吗?我期望看到诸如tenantId,applicationid等的内容。

我可以通过单击以下内容通过门户获取此信息:

Automationaccount>以帐户身份运行> Azure RunAs帐户

或通过

Automationaccount>连接> AzureRunAsConnection

但是看不到如何从PowerShell获取有关RunAs帐户的此信息?

谢谢。

xiezhanliang 回答:使用PowerShell获取Azure自动化帐户连接的服务主体

是的,您需要使用$conn = $automationAccount | Get-AzAutomationConnection -Name "AzureRunAsConnection"

也许是个错误?

这不是错误,因为这两个命令调用了不同的REST API。

在使用$conn = $automationAccount | Get-AzAutomationConnection时,它将调用此剩余api Connection - List By Automation AccountfieldDefinitionValues的详细信息将不会被公开,而将始终为null。您可以检查sample response或用提琴手捕捉Powershell的请求。

enter image description here

在使用$conn = $automationAccount | Get-AzAutomationConnection -Name "AzureRunAsConnection"时,它将调用此rest api Connection - GetfieldDefinitionValues将包含您想要的属性。

enter image description here

,

您自己在评论中回答了这个问题。但是只是为了阻止这个问题以未解决的方式出现:

$conn = $automationAccount | Get-AzAutomationConnection -Name "AzureRunAsConnection" 
本文链接:https://www.f2er.com/2825259.html

大家都在问