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 .
Thanks in advance.
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
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
Thanks .it worked.
Thanks for yur support.