VMware Cloud Community
GatsByMIg
Contributor
Contributor

Export Users, Pools, and VDI Description to CSV

Hello,

I think my title says it all.  I am very new with VMware and I was tasked to work on a project to gather the following information

UserName

Name

VDI Pool

VDI machine Description (Ram, CPU, Disk Space)

We are using vSphere 6.0

I am not sure if this is even possible, I wrote a PowerShell code to obtain the Users, VDI Groups and it works great, the information comes mainly from Active Directory, but i need to find a way to obtain the VDI Machine Description per user.

I was wondering if someone can help me with that.

I was able to find a way to get UserNames and VDI machines from VMWare Horizon View Admin, (we use VMware Horizon View 5.3), but the VDI description is still missing.

We would like to know how many people use 4GB Ram, 8, or 16, same with CPU, and Disk.. ETC.

I was able to get the information from the NON PERSISTENT VDI, but it is hard to find it from the PERSISTENT VDI, because each VDI can be different..

Thanks!

Reply
0 Kudos
1 Reply
jrodsguitar
Enthusiast
Enthusiast

This is not too difficult to accomplish if you know how to approach it.

Query the VDI data first with the VMware.Hv.Helper module (I am just one of the many contributors). You can get it from here:

PowerCLI-Example-Scripts/Modules/VMware.Hv.Helper at master · vmware/PowerCLI-Example-Scripts · GitH...

Use get-hvmachineSummary command to get the summary for each machine then utilize the get-vm command from PowerCLI 10 to get the CPU/RAM/DISK from the VM.

Here's an example script to get you jumpstarted:

#Jose Rodriguez

#jrodsguitar@gmail.com

#https://get-cj.com

if(!$cred){

$cred = Get-Credential

}

$vdiserver = 'VDI_Server_NAME'

$vcenter = 'Vcenter_Server_NAME'

connect-hvserver $vdiserver -Credential $cred

Connect-VIServer $vcenter -Credential $cred

$vms = Get-HVMachineSummary

$results = @()

foreach($vm in $vms){

     $machine = $null

     $machine = Get-VM -Name $vm.Base.Name

     $properties = @{

     UserName = $vm.NamesData.UserName

     MachineName = $vm.Base.Name

     VDIPool = $vm.NamesData.DesktopName

     Ram = $machine.memorymb

     CPU = $machine.numcpu

     DiskSpaceUsedGB = [math]::round($machine.UsedSpaceGB,2)

     DiskSpaceProvisionedGB = [math]::round($machine.ProvisionedSpaceGB,2)

     }

     $results += New-Object psobject -Property $properties

}

$results | export-csv -NoTypeInformation -path c:\me\test.csv

Blog: https://powershell.house/
Reply
0 Kudos