AGFlora
Enthusiast
Enthusiast

Get VM Name, MAC, IP

Jump to solution


Does anyone have a script handy that gets the VM name, MAC and IP from a text file containg specific VM names using the Get-Content function?

Thanks,

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

Try something like this

Get-vm -Name (Get-Content -Path C:\vmnames.txt) |

Select Name,

    @{N="IP addr";E={[string]::Join(',',$_.Guest.IPAddress)}},

    @{N="MAC addr";E={[string]::Join(',',($_.Guest.Nics | %{$_.MacAddress}))}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership

Try something like this

Get-vm -Name (Get-Content -Path C:\vmnames.txt) |

Select Name,

    @{N="IP addr";E={[string]::Join(',',$_.Guest.IPAddress)}},

    @{N="MAC addr";E={[string]::Join(',',($_.Guest.Nics | %{$_.MacAddress}))}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
AGFlora
Enthusiast
Enthusiast

Perfect...Thanks Luc!

0 Kudos