VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

List all IP addresses in new line

Hi,

Please help to get the list of all the IP Address in new or different lines

Get-VM db1 | Select @{N='VM Name';E={$_.Name}}, @{N="IP Address";E={[string]::Join(',',$_.guest.IPAddress)}}

Current Output

VM Name                                                                                             IP Address
-------                                                                                             ----------
db1                                                                                                 169.254.1.40,192.168.2.99

I would like to get output as below

VM Name                          IP Address
-------                                ----------
db1                                   169.254.1.40

db1                                   192.168.2.99

Please help!!!!

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-VM -Name db1 -PipelineVariable vm |

ForEach-Object -Process {

    $_.guest.IPAddress |

    Select @{N='VM Name';E={$vm.Name}},

        @{N="IP Address";E={$_}}

}


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-VM -Name db1 -PipelineVariable vm |

ForEach-Object -Process {

    $_.guest.IPAddress |

    Select @{N='VM Name';E={$vm.Name}},

        @{N="IP Address";E={$_}}

}


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

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Thank you very much Smiley Happy

0 Kudos