Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 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"
@gowatana
Copy link
Author

gowatana commented Aug 2, 2022

下記の投稿むけ。
Horizon 8 デスクトップ プールの状況を PowerCLI で取得してみる。
https://vm.gowatana.jp/entry/2022/08/03/024321

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment