Hello,
I would like to get from vSphere Distributed Switch total ports and available ports. I have tried few ways to get this informations, but i could not find a way to accomplish this. Is any chance to create this kind of script?
Thanks!
Have a look at Script to get DVportgroup or Standardswtich portgroup Name, Vlan id, total ports and available ports
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I looked on that script but for my project I need total number from that Vswitch if you know what i mean.
Ok, got it (I think).
Try like this
Get-VDSwitch |
Select Name,
@{N='Total Ports';E={$_.NumPorts}},
@{N='Available Ports';E={
$vds = $_
$hPorts = $vds.ExtensionData.Config.Host.UplinkPortKey.Count
$vPorts = (Get-View -Id $vds.ExtensionData.Summary.Vm | %{
$_.Config.Hardware.Device |
where{$_.Backing -and
$_.Backing.GetType().Name -match "distributed" -and
$_.Backing.Port.SwitchUuid -eq $vds.ExtensionData.Uuid}}).Count
$vds.NumPorts - $hPorts - $vPorts
}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I need some packeg or something like that because I get this errror:
Get-VDSwitch : The term 'Get-VDSwitch' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a
path was included, verify that the path is correct and try again.
Which PowerCLI version are you running?
Do a Get-PowerCLIVersion
If you can upgrade to the latest version, which is modules only, you can just execute the following line once before running the script.
Get-Module -Name VMware* -ListAvailable | Import-Module
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
PowerCLI Version
----------------
VMware vSphere PowerCLI 5.8 Release 1 build 2057893
---------------
Snapin Versions
---------------
VMWare AutoDeploy PowerCLI Component 5.5 build 1983942
VMWare ImageBuilder PowerCLI Component 5.5 build 1983942
VMware License PowerCLI Component 5.5 build 1265954
VMware Storage PowerCLI Component 5.8 build 2057894
VMware VDS PowerCLI Component 5.8 build 2031581
VMware vSphere PowerCLI Component 5.8 build 2031581
Is there a specific reason you're on that older release?
Or can you upgrade to the latest version?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
unfortunately i need to kep this version because is a productive enviroment and i cannot upgrade to last version because currently we have a lot of script running over this version, so it will take a lot of work and time if i will upgrade to last version
I see.
In that case try replacing the Get-VDSwitch cmdlet by
Get-VirtualSwitch -Distributed
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Just perfect. Work as was expected. Thank you very much!
