Created
August 2, 2022 17:31
-
-
Save gowatana/5faafee5fd023b25def29b1a797a4eed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PowerCLI Demo: Get Horizon Desktop Pool status at Home Lab | |
# Auther: gowatana | |
# Usage: | |
# PowerCLI> Connect-HVServer | |
# PowerCLI> ./get_desktop_pool_status_count.ps1 "Desktop_Pool" | |
$pool_name = $args[0] | |
$html_file_name = "desktop_status_count_" + $pool_name + ".html" | |
$time_stamp = Get-Date -f "yyyy/MM/dd HH:mm:ss K" | |
$desktops = Get-HVMachine -PoolName $pool_name | |
$desktops_status = $desktops | select ` | |
@{N="DesktopPool";E={$_.Base.DesktopName}}, | |
@{N="Desktop";E={$_.Base.Name}}, | |
@{N="BasicState";E={$_.Base.BasicState}}, | |
@{N="SessionCount";E={$_.Base.Session.count}} | |
# Output Desktop Table | |
$desktops_status | ft -AutoSize | |
# Get Desktop Pool Status Summary | |
$desktop_status_table = $desktops_status | Group-Object BasicState | | |
Sort-Object Name | select ` | |
@{N="DesktopStatus";E={$_.Name}}, | |
@{N="DesktopCount";E={$_.Count}} | |
# Output Desktop Pool Status Summary | |
$desktop_status_table | ft -AutoSize | |
# Output HTML | |
$desktop_status_table | ConvertTo-Html ` | |
-Title "Pool Status Report" ` | |
-PreContent " | |
<h3>Desktop status count</h3> | |
<p>Pool: $pool_name</p><hr>" ` | |
-PostContent "<hr><p>Timestamp: $time_stamp</p>" | | |
Out-File -Encoding utf8 -FilePath $html_file_name | |
Write-Host "HTML Report: $html_file_name" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
下記の投稿むけ。
Horizon 8 デスクトップ プールの状況を PowerCLI で取得してみる。
https://vm.gowatana.jp/entry/2022/08/03/024321