Reputation: 944
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
Upvotes: 1
Views: 3332
Reputation: 13954
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
Upvotes: 1