Reputation: 570
I am using azureRm commads in powershell to create virtual machines in azure. And after i create one I would like to get its IP address into variable, but I could not find any azureRm commands to do so. Could anybody help me?
Upvotes: 0
Views: 998
Reputation: 11
I'm sure this can be made a bit more compact/efficient, but here is what I'd use in a pinch:
$vmname = "<your-vm-name>"
$ip = (Get-AzureRmNetworkInterface | Where-Object {($_.VirtualMachine.id).Split("/")[-1] -like $vmname}).IpConfigurations.PrivateIpAddress
Upvotes: 1
Reputation: 47
When you are using AzureRM, the IP is no more linked to the "VM" ressource. You need to get the network adapter of your VM and then the IP configured for this on this ressource adapter. Get-AzureRmNetworkInterface
Hope this help.
Upvotes: 1