简体   繁体   中英

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. How do I find the FQDN of the VM from the script that creates it?

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?

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.

We can use this command to get 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

New-AzureRmPublicIpAddress  -Name -ResourceGroupName -Location -DomainNameLabel

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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