I need to get a list of VDPortGroups from each datacenter and eac cluster in my vCenter server called "Junkyard".
I need the output to be formatted in a table like below....
vCenterServer | DatacenterName | ClusterName | VDPortGroup |
Junkyard | Scrappy | ScrappyDoo | dv-prod |
Junkyard | Crappy | CrappyDoo | dv-dev |
Junkyard | Snappy | SnappyDoo | dv-test |
Junkyard | Nappy | NappyDoo | dv-kaboom |
That's just a sample, there actually a hundred more...…..lol
Now, I apparently have an old version of PowerCLI, see below.....
Every time I try and upgrade, PowerCLI prompts for authentication and I can't have that. Will try and fix later.
Get-Module -Name VMware* -ListAvailable
Directory: C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Binary 6.0.0.0 VMware.DeployAutomation
Binary 6.0.0.0 VMware.ImageBuilder
Binary 6.5.0.4... VMware.VimAutomation.Cis.Core
Binary 6.5.0.4... VMware.VimAutomation.Cloud
Manifest 6.5.0.4... VMware.VimAutomation.Common
Binary 6.5.0.2... VMware.VimAutomation.Core HookGetViewAutoCompleter
Binary 6.0.0.0 VMware.VimAutomation.HA
Binary 7.0.2.4... VMware.VimAutomation.HorizonView
Binary 6.5.0.4... VMware.VimAutomation.License
Binary 6.5.0.4... VMware.VimAutomation.PCloud
Manifest 6.5.0.4... VMware.VimAutomation.Sdk Get-PSVersion
Binary 6.5.0.4... VMware.VimAutomation.Storage
Binary 6.5.0.4... VMware.VimAutomation.Vds
Binary 6.5.0.4... VMware.VimAutomation.vROps
Binary 6.0.0.0 VMware.VumAutomation
You obviously still have a MSI-based installed of PowerCLI.
When that is installed for AllUsers, you most probably need administrator authority to uninstall the package.
For the script try something like this
$vcName = 'Junkyard'
Get-Datacenter -Server $vcName -PipelineVariable dc |
ForEach-Object -Process {
Get-Cluster -Location $dc -Server $vcName -PipelineVariable cluster |
ForEach-Object -Process {
Get-VMHost -Location $cluster -Server $vcName |
Get-VDswitch -Server $vcName |
Get-VDPortgroup -Server $vcName |
Select @{N='vCenter';E={$vcName}},
@{N='Datacenter';E={$dc.Name}},
@{N='Cluster';E={$cluster.Name}},
@{N='VDPortgroup';E={$_.Name}}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You obviously still have a MSI-based installed of PowerCLI.
When that is installed for AllUsers, you most probably need administrator authority to uninstall the package.
For the script try something like this
$vcName = 'Junkyard'
Get-Datacenter -Server $vcName -PipelineVariable dc |
ForEach-Object -Process {
Get-Cluster -Location $dc -Server $vcName -PipelineVariable cluster |
ForEach-Object -Process {
Get-VMHost -Location $cluster -Server $vcName |
Get-VDswitch -Server $vcName |
Get-VDPortgroup -Server $vcName |
Select @{N='vCenter';E={$vcName}},
@{N='Datacenter';E={$dc.Name}},
@{N='Cluster';E={$cluster.Name}},
@{N='VDPortgroup';E={$_.Name}}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I have admin rights. I ran everythin on a "run as..." also but same results.
Should I do a full uninstall then reinstall from the link you sent previously?
Thanks
Since it looks to be a MSI installation, I would advise to first try and uninstall via the Control Panel - Programs and Features.
Then manually remove the folder C:\Program Files (x86)\VMware\Infrastructure\PowerCLI and everything in it, should it still be there.
Then, perhaps do a reboot to be on the safe side first, install PowerCLI again with the Install-Module cmdlet.
The steps are documented in more detail in Welcome PowerCLI to the PowerShell Gallery – Install Process Updates
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
HI Lucd,
Can we get vms count each cluster using below script ?
vcName = 'Junkyard'
Get-Datacenter -Server $vcName -PipelineVariable dc |
ForEach-Object -Process {
Get-Cluster -Location $dc -Server $vcName -PipelineVariable cluster |
ForEach-Object -Process {
Get-VMHost -Location $cluster -Server $vcName |
Get-VDswitch -Server $vcName |
Get-VDPortgroup -Server $vcName |
Select @{N='vCenter';E={$vcName}},
@{N='Datacenter';E={$dc.Name}},
@{N='Cluster';E={$cluster.Name}},
@{N='VDPortgroup';E={$_.Name}}
}
}
Try adding this calculated property
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks lucd. Its giving cluster vm count. expecting each portgroup vms count.
You did ask "Can we get vms count each cluster using below script ?"
In any case, try like this
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Lucd..