Created
March 7, 2025 22:05
-
-
Save Postrediori/cb1aa28312baf3566669433271b20be4 to your computer and use it in GitHub Desktop.
Get IP address of a Hyper-V guest system
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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