【问题标题】:Add azure vm to Active Directory during deployment using powershell and azure runbooks在部署期间使用 powershell 和 azure runbook 将 azure vm 添加到 Active Directory
【发布时间】:2018-09-22 14:14:56
【问题描述】:

有没有办法在部署期间使用 Azure Runbook 和 Powershell 将 Azure VM 添加到 Active Directory 域?

我在 Azure 中有一个使用 PowerShell 的 Runbook。 PowerShell 调用模板来部署 VM,如下所示。我更喜欢使用 PowerShell 而不是 ARM 模板,有没有办法做到这一点?

New-AzureRmResourceGroupDeployment -ResourceGroupName $resourcegroup `
    -TemplateUri $vm_template_uri -TemplateParameterObject $ServerParameters

【问题讨论】:

  • 用 arm 模板做这件事要好得多,但如果你想用 powershell 做——那就做吧。 Enter-pssesession 会让你连接到虚拟机并运行命令
  • 看看这个链接 blogs.msdn.microsoft.com/igorpag/2016/01/25/… 它展示了如何使用 PowerShell 的扩展来做到这一点。
  • 你能推荐一个模板吗,我试过在这里用一个,但没用:raw.githubusercontent.com/Azure/azure-quickstart-templates/…
  • 我尝试了模板,但不断收到以下错误 - 模板部署返回以下错误:09:06:11 - “代码”:“VMExtensionProvisioningError”,09:06:11 - “消息”: "VM 在处理扩展 'joindomain' 时报告失败。错误消息:\"加入域 'domain.local' 时发生异常\"。"

标签: powershell azure active-directory


【解决方案1】:

这对我很有效: How to join a VM to a domain by PowerShell in Azure

$DomainName = "your_domain_name"
$VMName = "your_VM_Name"
$credential = Get-Credential your_Domain_account
$ResourceGroupName = "your_RG_name" 
Set-AzVMADDomainExtension -DomainName $DomainName -VMName $VMName -Credential $credential -ResourceGroupName $ResourceGroupName -JoinOption 0x00000001 -Restart -Verbose

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-14
    • 1970-01-01
    • 2022-01-04
    • 2017-09-03
    • 1970-01-01
    相关资源
    最近更新 更多