简体   繁体   English

Azure Powershell-如何从VM获取FQDN?

[英]Azure powershell - how to get FQDN from a VM?

I am automating the deployment of several Azure VMs and I want to WinRM into each of them to finish the deployment. 我正在自动化几个Azure VM的部署,并且我想将WinRM集成到每个Azure VM中以完成部署。 How do I find the FQDN of the VM from the script that creates it? 如何从创建虚拟机的脚本中找到虚拟机的FQDN?

I'm looking for: 我在找:

$psVirtualMachine = Add-AzureRmVMNetworkInterface -VM $psVirtualMachine -Id $Nic.Id

$CreateNewVM = New-AzureRMVM -ResourceGroupName $ResourceGroupName -Location $GeoLocation -VM $psVirtualMachine

Enter-PSSession -ConnectionUri https://<-- $CreateNewVM.FQDN -->:5986 -Credential $Cred -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck) -Authentication Negotiate

How do I find the FQDN of the VM from the script that creates it? 如何从创建虚拟机的脚本中找到虚拟机的FQDN?

By default, Azure will not create FQDN for Azure VM, we can use powershell to set public IP address settings to set FQDN for Azure VM. 默认情况下,Azure不会为Azure VM创建FQDN,我们可以使用Powershell设置公共IP地址设置来为Azure VM设置FQDN。

We can use this command to get FQDN: 我们可以使用以下命令获取FQDN:

$FQDN = (Get-AzureRmPublicIpAddress -Name 'name of public IP' -ResourceGroupName jasonvm).DnsSettings.Fqdn

Like this: 像这样:

PS C:\Users> (Get-AzureRmPublicIpAddress -Name 'jasonvm-ip' -ResourceGroupName jasonvm).DnsSettings.Fqdn
jasontest321.japaneast.cloudapp.azure.com

To set FQDN for Azure VM, we can use this powershell 要为Azure VM设置FQDN,我们可以使用此Powershell

New-AzureRmPublicIpAddress  -Name -ResourceGroupName -Location -DomainNameLabel

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM