![](/img/trans.png)
[英]How to run Azure CLI commands in Azure Automation Account Python Runbook or Powershell Runbook
[英]How to create automation schedule for Azure Automation Runbook from PowerShell to be run on Hybrid Worker?
我想從 PowerShell 為Azure Automation Runbook
運行手冊創建自動化計划。 我不希望它默認在 Azure 上運行,而是在Hybrid Worker
上運行,它存在於我的Hybrid worker groups
中。 所以我有這個命令:
Import-AzureRmAutomationRunbook -Name $runbookName `
-Path $scriptPath `
-ResourceGroupName $automationResourceGroupName `
-AutomationAccountName $automationAccountName `
-Type PowerShellWorkflow
Publish-AzureRmAutomationRunbook -Name $runbookName `
-AutomationAccountName $automationAccountName `
-ResourceGroupName $automationResourceGroupName
New-AzureRmAutomationSchedule -Name $runbookName `
-AutomationAccountName $automationAccountName `
-StartTime $StartTime `
-ExpiryTime $EndTime `
-DayInterval 1 `
-ResourceGroupName $automationResourceGroupName
可以從 Azure 門戶手動完成:
但我需要從 PowerShell 完成。 我在 MS 文檔上找不到它。
如果您使用的是AzureRm
模塊,只需使用Start-AzureRmAutomationRunbook
,將-RunOn
參數指定為您的Hybrid Worker group
的名稱。
Start-AzureRmAutomationRunbook –AutomationAccountName "MyAutomationAccount" –Name "Test-Runbook" -RunOn "MyHybridGroup"
參考(它使用新的Az
命令) - https://docs.microsoft.com/en-us/azure/automation/automation-hrw-run-runbooks#start-a-runbook-on-a-hybrid-runbook-工人
更新:
要計划 Runbook,可以使用Register-AzureRmAutomationScheduledRunbook
,指定-RunOn
參數。
Register-AzureRmAutomationScheduledRunbook -AutomationAccountName "Contoso17" -Name "Runbk01" -ScheduleName "Sched01" -ResourceGroupName "ResourceGroup01" -RunOn "MyHybridGroup"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.