Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Get-VMMacAddress {
- param ($mac)
- if ($mac -match "([0-9A-Fa-f]{4}[-.:]){2}([0-9A-Fa-f]{4})") {
- #change 4.4.4 format to 2:2:2:2:2:2
- $mactemp = $mac.Replace("-","").Replace(".","").Replace(":","")
- for ($i=$mactemp.Length -2 ; $i -gt 0 ;$i=$i-2){$mactemp=$mactemp.insert($i,":")}
- $mac = $mactemp
- }
- if ($mac -match "([0-9A-Fa-f]{2}[-.]){5}([0-9A-Fa-f]{2})") {
- #replace 2-2-2-2-2-2 format to 2:2:2:2:2:2
- $mac = $mac.Replace("-",":") }
- $vm=Get-VM | Get-NetworkAdapter | Where {$_.MacAddress -eq $mac}
- $vm | Select-Object Parent,Name,MacAddress
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement