2017-09-07 54 views
0

我正在自动部署几个Azure虚拟机,并且我想将WinRM安装到每个虚拟机中以完成部署。如何从创建虚拟机的脚本中找到虚拟机的FQDN?Azure powershell - 如何从虚拟机获取FQDN?

我在寻找:

$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 

回答

0

如何找到虚拟机的FQDN创建它的脚本?

默认情况下,天青不会为Azure的VM创建FQDN,我们可以使用PowerShell设置公网IP地址设置来设置FQDN为Azure的VM。

我们可以使用这个命令来获得FQDN:

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

像这样:

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

要为Azure的VM设置FQDN,我们可以用这个PowerShell的

New-AzureRmPublicIpAddress -Name -ResourceGroupName -Location -DomainNameLabel 
相关问题