troubleshooting Question

Retrieve Disk Information of VMs in vCloud Director 10.1.2

Avatar of RobSampson
RobSampsonFlag for Australia asked on
PowershellVirtualization* Vmware, PowerCLI,
2 Comments1 Solution22 ViewsLast Modified:
Hi experts, we have migrated from vCenter 6.5 to vCloud 10.1.2 and I need to update my scripts.
One that I have is to retrieve disk space capacity and free space of each Windows VM.
In the old script, first, I connect using Connect-VIServer, but now I have to use Connect-CIServer, which is fine.
Second, in the old script, I used this to get a list of running VMs
$Allvms = Get-View -ViewType “VirtualMachine” -filter @{”Guest.GuestState”=”^running$”}
In vCloud, I can use the below, but not sure it's completely accurate, but it should do
Get-CIVM -Status "PoweredOn" | Select Name
Then in the old script I checked if the VM was a Windows guest
If ($($vm.Guest.GuestFamily) -eq "windowsGuest") {
so it seems I can use this
If ($vm.GuestOSFullName -Like "Microsoft Windows*") {
Now comes the hard part....for me at least....I can't find a way to dig into the Guest properties, specifically the disk statistics.  In the old script I used

$Drives = $vm.Guest.Disk
ForEach ($DriveC in $drives) {
                #Calculations
                $Freespace = [math]::Round($DriveC.FreeSpace / 1MB)
                $Capacity = [math]::Round($DriveC.Capacity / 1MB)
                $SpaceOverview = "$Freespace" + "/" + "$capacity"
                $PercentFree = [math]::Round(($FreeSpace)/ ($Capacity) * 100)
                $Disk = $DriveC.DiskPath.Substring(0,2)
}
I've seen some code to invoke a web request to the vCloud API, but what I found provides total capacity, and not used space in the guest disk.

Would anyone be able to help me identify what I can use to get this information?

Thanks,

Rob.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros