次の PowerShell 関数によって、すべてのデスクトップ プールの現在の使用方法が判断され、最大容量にあるすべての自動プロビジョニング デスクトップ プールまたはリンク クローン デスクトップ プールのサイズが変更されます。
# PollAllPoolsUsage # Parameters # $increment Amount by which to increase a pool that is at maximum capacity (default = 5). function PollAllPoolsUsage { param ($increment) if(-not $increment){ $increment = 5 } # Retrieve all pool objects and check each one individually $pools = Get-Pool foreach ($pool in $pools){ PollPoolUsage $pool $increment } } # PollPoolUsage # Parameters # $Pool Pool object that represents the pool to be checked. # $increment Amount by which to increase pool that is at maximum capacity. function PollPoolUsage { param ($Pool, $increment) # Get a list of remote sessions for the pool (errors are suppressed) $remotes = Get-RemoteSession -pool_id $Pool.pool_id -ErrorAction SilentlyContinue # Count the remote sessions. $remotecount = 0 if($remotes){ $remotecount = ([Object[]]($remotes)).Count } # Determine the maximum number of desktops configured for a pool. $maxdesktops = 0 if($Pool.deliveryModel -eq "Provisioned"){ $maxdesktops = $Pool.maximumCount } else { $maxdesktops = $Pool.machineDNs.split(";").Count } # Output the usage statistics for a pool. Write-Output ("==== " + $Pool.pool_id + " ====") Write-Output ("Remote session count: " + $remotecount) Write-Output ("Maximum desktops: " + $maxdesktops) # If a pool is using all its desktops, increase its maximum size # or output a warning if it cannot be resized. if($maxdesktops -eq $remotecount){ if($Pool.deliveryModel -eq "Provisioned"){ # Pool type can be resized $newmaximum = [int]$Pool.maximumCount + [int]$increment if($Pool.desktopSource -eq "VC"){ # Resize an automatic pool Update-AutomaticPool -pool_id $Pool.pool_id -maximumCount $newmaximum } elseif ($Pool.desktopSource -eq "SVI"){ # Resize a linked-clone pool Update-AutomaticLinkedClonePool -pool_id $Pool.pool_id -maximumCount $newmaximum } Write-Output ("Pool " + $Pool.pool_id + " is using 100% of its desktops. Maximum VMs increased to " + $newmaximum) } else { # Pool type cannot be resized Write-Output ("Pool " + $Pool.pool_id + " is using 100% of its desktops. Consider increasing its capacity.") } } }