Skip to content

Instantly share code, notes, and snippets.

@vmwarecode
Created February 10, 2016 16:59
Show Gist options
  • Select an option

  • Save vmwarecode/e7ba8cdd362c45ce0a1e to your computer and use it in GitHub Desktop.

Select an option

Save vmwarecode/e7ba8cdd362c45ce0a1e to your computer and use it in GitHub Desktop.
Get VM ip and hostname
$vm = Get-VM
$vmview = $vm | Get-View
Foreach ($v in $vmview){
echo "-----------------------"
echo $v.Name
echo $v.Config.uuid
echo "-----------------------"
$Name = $v.Guest.HostName
If ($Name -ne $null -and $Name -ne ""){
echo $Name
Foreach ($nic in $v.Guest.Net){
$IP = $nic.IPAddress
echo $IP
}
}
}
echo "-----------------------"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment