Azure自动化:Runbook:它知道它是TenantID吗?

下午好

猜测,这是真的:

Azure Tenant
» Azure Subscription
  » Azure Automation
    » Runbook

因此,我有一个问题:

是否有一个PowerShell命令可用于获取Runbook在其中运行的TenantID?

wangkai5260929 回答:Azure自动化:Runbook:它知道它是TenantID吗?

是的,您可以使用此位:

(Get-AzContext).Tenant.Id

找出租户的GUID

,

如果要在Runbook中运行命令,可以使用以下命令:

$servicePrincipalConnection = Get-AutomationConnection -Name "AzureRunAsConnection"        
Write-Output $servicePrincipalConnection.TenantId

enter image description here

注意:有一个前提条件,当您创建自动化帐户时,您需要选择Create Azure Run As accountYes,否则选择AzureRunAsConnection 不存在。

enter image description here

本文链接:https://www.f2er.com/2384563.html

大家都在问