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 Solution24 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$”}

Open in new window

In vCloud, I can use the below, but not sure it's completely accurate, but it should do
Get-CIVM -Status "PoweredOn" | Select Name

Open in new window

Then in the old script I checked if the VM was a Windows guest
If ($($vm.Guest.GuestFamily) -eq "windowsGuest") {

Open in new window

so it seems I can use this
If ($vm.GuestOSFullName -Like "Microsoft Windows*") {

Open in new window

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)
}

Open in new window

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.
ASKER CERTIFIED SOLUTION
Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 2 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 2 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004