VMware Cloud Community
AGFlora
Enthusiast
Enthusiast
Jump to solution

Get VM Name, MAC, IP


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,

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
AGFlora
Enthusiast
Enthusiast
Jump to solution

Perfect...Thanks Luc!

Reply
0 Kudos