Tag Archives: PowerCLI

Monster VMs Mass Storage & How to check storage used

Jason Boche posted an interesting discovery with regards to Monster VMs and the amount of storage one would be sticking to them.  One of the large projects being designed today  has the likely reason to hit this limit with just a single VM.  This is pretty easy for that project to hit that as a single VM will have about 75TB assigned to it.   Since this design has 4 or 5 VMs of this size, which then means our standard ESXi Host will have around 300+ TB assigned to it.  Thankfully RDM isn’t impacted by this limit in theory, so there is a workaround available.  Not ideal and yet doable.

Instead one of the questions that came out of this news is “Does this issue impact the rest of our environment?”   Will this explain some random stability issues we have seen?

This script will return what every single host has in terms of VMDK files.  To use this script look at each host and see if the host itself is under the limits.  Then look at the cluster level based on the HA rules and see what the VMDK limits would be if a host failed.  That should give an idea of how close your clusters might be to hitting this limit.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
if ( -not (Get-PSSnapIn | where {$_.Name -eq "VMware.VimAutomation.Core"}) )
{ 
    Add-PSSnapin -Name "VMware.VimAutomation.Core"
}
 
$vcenters = "vCenter"
 
connect-viserver -server $vcenters -cred (Get-Credential)
 
$diskuse = @()
 
$clusters = get-cluster
foreach ($cluster in $clusters) {
    "Working on Cluster $cluster"
    $vmhosts = get-vmhost -Location $cluster
    foreach ($vmhost in $vmhosts) {
    "`tWorking on VMHost $vmhost"
        $vmlist = get-vm -location $vmhost
        $totalDisk = 0 
        foreach ($vm in $vmlist) {
            $view = $vm | get-View   
            foreach ($disk in $view.Guest.Disk) {
                $disksize = ([math]::Round($disk.Capacity/1MB))
                $totaldisk += $disksize
            }
         }
         "`t`tVM size: $totaldisk"
            $obj = new-object PSObject -Property @{
                Cluster = $cluster
                VMHost  = $vmhost
                TotalDiskMB = $totaldisk
            }
         $diskuse += $obj
    }
}
 
$diskuse | export-csv "OpenFileDiskUse.csv" -NoTypeInformation

With Default settings the magic numbers to look for:

  • ESXi 4.x – 4TB
  • ESXi 5.1 – 8TB

Using PowerCLI in an enterprise environment

Most enterprises take security very seriously.   As such it is extremely common to have a webproxy setup by default in your environment.   PowerCLI/Powershell are configured by default to Use System Proxy.   This means that when you attempt to use some of the cmdlets they will end up being attempted to get routed through the proxy.

Two cmdlets that do not work properly when this is happening are Install-VMHostPatch & Copy-DatastoreItem. A good indication of the proxy being involved is exceptions that have items like:
Proxy Authentication Required

To work around this wrap the code in a Set-PowerCLIConfiguration proxy avoidance.

1
2
3
4
5
6
$CurrentProxyCfg = Get-PowerCLIConfiguration
Set-PowerCLIConfiguration -ProxyPolicy NoProxy
...
Install-VMHostPatch [...]
...
Set-PowerCLIConfiguration -ProxyPolicy $CurrentProxyCfg.ProxyPolicy

Thanks to @cshanklin & @lucd for their assistance in aiming me down the right path.