VMware Cloud Community
AGFlora
Enthusiast
Enthusiast
Jump to solution

vCenter Inventroy

Hi

Is there a way to list the hierarchy in vCenter?

vCenter server, Datacneter, Cluster and export them to a csv file?

Thanks

0 Kudos
1 Solution

Accepted Solutions
RvdNieuwendijk
Leadership
Leadership
Jump to solution

My script lists the vCenter servers in the vCenter property.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition

View solution in original post

0 Kudos
8 Replies
LucD
Leadership
Leadership
Jump to solution

It depends how deep you want the tree structure to be.

My Get the folderpath post gives you the full paths.

If you need more details, for example also list the VMs, the function can be adapted.


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

RvdNieuwendijk
Leadership
Leadership
Jump to solution

You can list the datacenter and cluster hierarchy with:

& { foreach ($Datacenter in (Get-Datacenter)) {
      foreach ($Cluster in (Get-Cluster -Location $Datacenter)) {
        New-Object -TypeName PSObject -Property @{
          vCenter = $Datacenter.Uid.Split("@")[1].Split(":")[0]
          Datacenter = $Datacenter.Name
          Cluster = $Cluster.Name
        }
      }
    }
  } |
Select-Object -Property vCenter,Datacenter,Cluster |
Export-Csv -Path DatacenterInfo.csv -NoTypeInformation -UseCulture 

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
AGFlora
Enthusiast
Enthusiast
Jump to solution

Is it possible to also list the vCenter servers?

0 Kudos
RvdNieuwendijk
Leadership
Leadership
Jump to solution

My script lists the vCenter servers in the vCenter property.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
AGFlora
Enthusiast
Enthusiast
Jump to solution

Sorry I did see thiis after I ran the script.

Exactlly what I was looking for thanks!

0 Kudos
AGFlora
Enthusiast
Enthusiast
Jump to solution

HI

Can we also add the following cluster features?

HA.png

DRS.png

0 Kudos
RvdNieuwendijk
Leadership
Leadership
Jump to solution

Sure. The next PowerCLI script adds the HAEnabled, DrsEnabled and DrsMode properties to the output.

& { foreach ($Datacenter in (Get-Datacenter)) {
      foreach ($Cluster in (Get-Cluster -Location $Datacenter)) {
        New-Object -TypeName PSObject -Property @{
          vCenter = $Datacenter.Uid.Split("@")[1].Split(":")[0]
          Datacenter = $Datacenter.Name
          Cluster = $Cluster.Name
          HAEnabled = $Cluster.HAEnabled
          DrsEnabled = $Cluster.DrsEnabled
          DrsMode = $Cluster.DrsMode
        }
      }
    }
  } |
Select-Object -Property vCenter,Datacenter,Cluster,HAEnabled,DrsEnabled,DrsMode |
Export-Csv -Path DatacenterInfo.csv -NoTypeInformation -UseCulture 

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
AGFlora
Enthusiast
Enthusiast
Jump to solution

Perfect. Thanks!

0 Kudos