Skip to content

Instantly share code, notes, and snippets.

@gswallow
Created February 7, 2019 15:47
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 gswallow/addb3bd6af1dbc350e19a9bc76d97a02 to your computer and use it in GitHub Desktop.
Save gswallow/addb3bd6af1dbc350e19a9bc76d97a02 to your computer and use it in GitHub Desktop.
Find VMs by MAC address
#!/bin/bash
for vm in $(govc find -i=true / -type m); do
govc object.collect -json=true $vm config | jq -r '.[] | select(.Val.Hardware.Device[].MacAddress == "00:50:56:b4:0a:1b") | .Val.Name'
govc object.collect -json=true $vm config | jq -r '.[] | select(.Val.Hardware.Device[].MacAddress == "00:50:56:b7:06:6f") | .Val.Name'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment