Skip to content

Instantly share code, notes, and snippets.

@Postrediori
Created March 7, 2025 22:05
Show Gist options
  • Save Postrediori/cb1aa28312baf3566669433271b20be4 to your computer and use it in GitHub Desktop.
Save Postrediori/cb1aa28312baf3566669433271b20be4 to your computer and use it in GitHub Desktop.
Get IP address of a Hyper-V guest system
# Get VM IP address by name
# Examples:
# .\Get-VM-IP.ps1 -vm_name "Ubuntu 24.04 Server"
param([string]$vm_name = "Windows 10")
$mac = (get-vm -name $vm_name | select -ExpandProperty networkadapters| select -ExpandProperty macaddress) -replace "([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})", '$1-$2-$3-$4-$5-$6'
Get-NetNeighbor -LinkLayerAddress $mac | select -ExpandProperty IPAddress
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment