英文:
Getting the service principal for an Azure Automation Account connection using PowerShell
问题
我知道如何使用Get-AutomationAccount在运行自动化帐户内的运行簿时检索连接详细信息。
但是,如果我想要能够报告在运行簿作业之外使用的AzureRunAsConnection的服务主体,该怎么办?
我尝试了类似以下的方法:
$automationAccount = Get-AzAutomationAccount -ResourceGroupName $rg -Name $name
$conn = $automationAccount | Get-AzAutomationConnection
$conn.FieldDefinitionValues
但是,FielDefinitionValues哈希表中什么都没有吗?我希望能看到租户ID、ApplicationId等信息。
我可以通过在门户上点击以下方式获取此信息:
AutomationAccount > Run as accounts > Azure RunAs Account
或者通过
AutomationAccount > Connections > AzureRunAsConnection
但是不知道如何通过PowerShell获取RunAs帐户的此信息?
提前感谢。
英文:
I know how Get-AutomationAccount can be used to retrieve the connection details internally while running a runbook within an automation account.
However, what if I want to be able to report on the service principal being used by the AzureRunAsConnection external to a runbook job?
I've tried something like the following:
$automationAccount = Get-AzAutomationAccount -ResourceGroupName $rg -Name $name
$conn = $automationAccount | Get-AzAutomationConnection
$conn.FieldDefinitionValues
However, the FielDefinitionValues hashtable has nothing in it? I was expecting to see things like tenantId, ApplicationId, etc.
I can get this information via the portal by clicking on:
> AutomationAccount > Run as accounts > Azure RunAs Account
or by
> AutomationAccount > Connections > AzureRunAsConnection
But can't see how I can get this info for the RunAs Account from PowerShell?
Thanks in advance.
答案1
得分: 1
是的,您需要使用$conn = $automationAccount | Get-AzAutomationConnection -Name "AzureRunAsConnection"
。
>可能是个bug?
这不是bug,因为这两个命令调用不同的REST API。
当使用$conn = $automationAccount | Get-AzAutomationConnection
时,它调用了这个REST API Connection - List By Automation Account
,fieldDefinitionValues
的详细信息不会被公开,它将始终为null
。您可以查看示例响应或使用Fiddler捕获PowerShell的请求。
当使用$conn = $automationAccount | Get-AzAutomationConnection -Name "AzureRunAsConnection"
时,它调用了这个REST API Connection - Get
。fieldDefinitionValues
将包括您想要的属性。
英文:
Yes, you need to use $conn = $automationAccount | Get-AzAutomationConnection -Name "AzureRunAsConnection"
.
>Maybe a bug?
It is not a bug, because the two commands call different REST APIs.
When using $conn = $automationAccount | Get-AzAutomationConnection
, it calls this 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 or catch the request of the powershell with fiddler.
When using $conn = $automationAccount | Get-AzAutomationConnection -Name "AzureRunAsConnection"
, it calls this rest api Connection - Get
. The fieldDefinitionValues
will include the properties you want.
答案2
得分: 0
$conn = $automationAccount | Get-AzAutomationConnection -Name "AzureRunAsConnection"
英文:
You answered this yourself in the comments. But just to stop this question coming up as unanswered:
$conn = $automationAccount | Get-AzAutomationConnection -Name "AzureRunAsConnection"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论