VMware Cloud Community
jvm2016
Hot Shot
Hot Shot
Jump to solution

standard switch configuration accross cluster_powercli

Hi Luc/All

could you please suggest if there is a way to replace common string .

following is what i am running to get standard switch configurations accross entire cluster .

$cluster=read-host "provide the cluster name"

$esxi_hosts=get-cluster $cluster|get-vmhost

foreach ($esxi in $esxi_hosts)

{

$esxi|select @{N='esxiname';E={$_.name}},@{N='portgroups';E={$_.NetworkInfo.VirtualSwitch.extensiondata.Portgroup}},@{N='standard switch';E={$esxi.NetworkInfo.VirtualSwitch.extensiondata.name}},@{N='PhyNics';E={$_.networkinfo.virtualswitch.extensiondata.pnic}}

}

output is following .somehow split method is little complicated.

is there any way to remove key-vim.host.physicalNic-   part to get clean output .

pastedImage_0.png

Thanks in advance.

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You could do something like this instead

$cluster=Read-Host "provide the cluster name"

$esxi_hosts=Get-Cluster $cluster | Get-VMHost

foreach ($esxi in $esxi_hosts)

{

    $esxi|

    select @{N='esxiname';E={$_.name}},

        @{N='portgroups';E={($_.NetworkInfo.VirtualSwitch | Get-VirtualPortgroup | Select -ExpandProperty Name) -join '|'}},

        @{N='standard switch';E={$esxi.NetworkInfo.VirtualSwitch.extensiondata.name}},

        @{N='PhyNics';E={($_.networkinfo.virtualswitch | Select -ExpandProperty Nic) -join '|'}}

}


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

View solution in original post

2 Replies
LucD
Leadership
Leadership
Jump to solution

You could do something like this instead

$cluster=Read-Host "provide the cluster name"

$esxi_hosts=Get-Cluster $cluster | Get-VMHost

foreach ($esxi in $esxi_hosts)

{

    $esxi|

    select @{N='esxiname';E={$_.name}},

        @{N='portgroups';E={($_.NetworkInfo.VirtualSwitch | Get-VirtualPortgroup | Select -ExpandProperty Name) -join '|'}},

        @{N='standard switch';E={$esxi.NetworkInfo.VirtualSwitch.extensiondata.name}},

        @{N='PhyNics';E={($_.networkinfo.virtualswitch | Select -ExpandProperty Nic) -join '|'}}

}


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

jvm2016
Hot Shot
Hot Shot
Jump to solution

Thanks .it worked.

Thanks for yur support.

0 Kudos