Skip to content

Instantly share code, notes, and snippets.

@tonysangha
Last active December 12, 2016 04:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonysangha/6e646cbb536fdd9faa861bc5f642c98b to your computer and use it in GitHub Desktop.
Save tonysangha/6e646cbb536fdd9faa861bc5f642c98b to your computer and use it in GitHub Desktop.
Get MAC & IP using PowerCLI
$vms = get-vm
# Get VM Name based on a MAC
foreach ($vm in $vms){
if(get-networkadapter $vm | where-object {$_.MacAddress -eq "MAC-ADDRESS"})
{
write-host $vm
}
}
# Get VM IP Address based on name
Get-VM | where-object {$_.name -eq "VM-NAME"} | Select Name, @{N="IP Address";E={@($_.guest.IPAddress[0])}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment