使用 PowerShell 获取 Azure 自动化帐户连接的服务主体
Getting the service principal for an Azure Automation Account connection using PowerShell
我知道如何使用 Get-AutomationAccount 在内部检索连接详细信息,同时 运行 自动化帐户中的运行手册。
但是,如果我希望能够报告 Runbook 作业外部的 AzureRunAsConnection 使用的服务主体,该怎么办?
我试过类似下面的方法:
$automationAccount = Get-AzAutomationAccount -ResourceGroupName $rg -Name $name
$conn = $automationAccount | Get-AzAutomationConnection
$conn.FieldDefinitionValues
但是,FielDefinitionValues 哈希表中没有任何内容?我期待看到 tenantId、ApplicationId 等内容
我可以通过单击以下门户网站获取此信息:
AutomationAccount > Run as accounts > Azure RunAs Account
或
AutomationAccount > Connections > AzureRunAsConnection
但看不到如何从 PowerShell 获取 RunAs 帐户的此信息?
提前致谢。
你在评论中自己回答了这个问题。但只是为了阻止这个问题作为未回答的问题出现:
$conn = $automationAccount | Get-AzAutomationConnection -Name "AzureRunAsConnection"
是的,您需要使用 $conn = $automationAccount | Get-AzAutomationConnection -Name "AzureRunAsConnection"
。
Maybe a bug?
这不是错误,因为这两个命令调用了不同的 REST API。
当使用$conn = $automationAccount | Get-AzAutomationConnection
时,它调用这个rest api Connection - List By Automation Account
, the details of fieldDefinitionValues
will not be exposed, it will always be null
. You could check the sample response或者用fiddler捕捉powershell的请求。
当使用$conn = $automationAccount | Get-AzAutomationConnection -Name "AzureRunAsConnection"
时,它称这个休息api Connection - Get
。 fieldDefinitionValues
将包含您想要的属性。
我知道如何使用 Get-AutomationAccount 在内部检索连接详细信息,同时 运行 自动化帐户中的运行手册。
但是,如果我希望能够报告 Runbook 作业外部的 AzureRunAsConnection 使用的服务主体,该怎么办?
我试过类似下面的方法:
$automationAccount = Get-AzAutomationAccount -ResourceGroupName $rg -Name $name
$conn = $automationAccount | Get-AzAutomationConnection
$conn.FieldDefinitionValues
但是,FielDefinitionValues 哈希表中没有任何内容?我期待看到 tenantId、ApplicationId 等内容
我可以通过单击以下门户网站获取此信息:
AutomationAccount > Run as accounts > Azure RunAs Account
或
AutomationAccount > Connections > AzureRunAsConnection
但看不到如何从 PowerShell 获取 RunAs 帐户的此信息?
提前致谢。
你在评论中自己回答了这个问题。但只是为了阻止这个问题作为未回答的问题出现:
$conn = $automationAccount | Get-AzAutomationConnection -Name "AzureRunAsConnection"
是的,您需要使用 $conn = $automationAccount | Get-AzAutomationConnection -Name "AzureRunAsConnection"
。
Maybe a bug?
这不是错误,因为这两个命令调用了不同的 REST API。
当使用$conn = $automationAccount | Get-AzAutomationConnection
时,它调用这个rest api Connection - List By Automation Account
, the details of fieldDefinitionValues
will not be exposed, it will always be null
. You could check the sample response或者用fiddler捕捉powershell的请求。
当使用$conn = $automationAccount | Get-AzAutomationConnection -Name "AzureRunAsConnection"
时,它称这个休息api Connection - Get
。 fieldDefinitionValues
将包含您想要的属性。