在Azure中使用Powershell创建Hybridworker错误

798qvoo8  于 12个月前  发布在  Shell
关注(0)|答案(1)|浏览(183)

我正在使用下面的代码在辅助(DR)资源组中创建Hybrid worker,并将其添加到主资源组中自动化帐户中的hybridworker组,但操作失败,并显示错误

$rgDRname = 'rgjt4061rbdr'
   $rgname = 'rgjt4061rb'
   $aaname = 'aajt4061rb'
   $hybridWorkerGroupName = 'hwrvmjt4061rbDNS1'

   # Get the Hybrid Worker Group
   $hybridWorkerGroup = Get-AzAutomationHybridWorkerGroup -ResourceGroupName $rgname -          AutomationAccountName $aaname -Name $hybridWorkerGroupName

   $vmDNS1resource = Get-AzVM -ResourceGroupName $rgDRname | Where-Object { $_.Name -like "vm*DNS1" }
   [string]$vmDNS1resourceid = $vmDNS1resource.Id

   # Create a new Hybrid Worker configuration
   $hybridWorkerConfiguration = @{
       ResourceGroupName = $rgname
       AutomationAccountName = $aaname
       VmResourceId = $vmDNS1resourceid 
       HybridRunbookWorkerGroupName = $hybridWorkerGroupName
       Name = $vmDNS1resource.Name
   }

   # Add the new Hybrid Worker to the group
   New-AzAutomationHybridRunbookWorker @hybridWorkerConfiguration

字符串
我得到了下面的错误

This is the error i have New-AzAutomationHybridRunbookWorker : The hybrid runbook worker id 'vmjt4061rbDNS1' is not in proper GUID format.
At line:1 char:1
+ New-AzAutomationHybridRunbookWorker @hybridWorkerConfiguration | gm
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [New-AzAutomationHybridRunbookWorker], ErrorResponseException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Automation.Cmdlet.NewAzureAutomationHybridRunbookWorker


Powershell命令失败。
如果有一种方法,我可以使用微软图形代替.这将是伟大的.

qco9c6ql

qco9c6ql1#

您需要传递-Name属性的值,如本文档中关于如何创建和管理混合工作进程的内容所述。
我已经修改了上面的共享PowerShell脚本,并使用下面的脚本,我可以毫无问题地部署混合Runbook worker。

$rgDRname = 'rgjt4061rbdr'
   $rgname = 'rgjt4061rb'
   $aaname = 'aajt4061rb'
   $hybridWorkerGroupName = 'hwrvmjt4061rbDNS1'
   $workerName= New-Guid

   $vmDNS1resource = Get-AzVM -ResourceGroupName $rgDRname | Where-Object { $_.Name -like "vm*DNS1" }
   $vmDNS1resourceid = $vmDNS1resource.Id

   # Create a new Hybrid Worker configuration
   $hybridWorkerConfiguration = @{
       ResourceGroupName = $rgname
       AutomationAccountName = $aaname
       VmResourceId = $vmDNS1resourceid 
       HybridRunbookWorkerGroupName = $hybridWorkerGroupName
       Name = $workerName
   }

   # Add the new Hybrid Worker to the group
   New-AzAutomationHybridRunbookWorker @hybridWorkerConfiguration

字符串

相关问题