{"id":4491,"date":"2016-09-08T06:00:59","date_gmt":"2016-09-08T14:00:59","guid":{"rendered":"https:\/\/www.atumvirt.com\/?p=4491"},"modified":"2016-09-08T06:00:59","modified_gmt":"2016-09-08T14:00:59","slug":"checking-the-percentage-of-desktops-available-in-each-xendesktop-site","status":"publish","type":"post","link":"https:\/\/avtempwp.azurewebsites.net\/2016\/09\/checking-the-percentage-of-desktops-available-in-each-xendesktop-site\/","title":{"rendered":"[Script] Checking the Percentage of Desktops Available in Each XenDesktop Site"},"content":{"rendered":"

When you manage multiple sites you may find that Citrix Director lacks an \u201cat-a-glance\u201d view of the status of multiple sites. This becomes extra apparent in a large pod-based design where multiple sites may exist within the same datacenter or in an active-active datacenter setup. With VDI, it is important to check the total number of VM\u2019s that are available for brokering. If the number is too low, you could be faced with a boot storm (assuming you have powered off virtual machines) if a large number of users log in. Or worse, you may not have available capacity. It is important to catch such incidents before they happen. Therefore, I present to you a script to output a simple HTML formatted table that can be incorporated into existing monitoring dashboards or sites (such as SharePoint).<\/p>\n

\"clip_image001\"<\/a><\/p>\n

Figure 1 Sample table output from script<\/p>\n

\u00a0\u00a0 <#\n\u00a0\u00a0\u00a0 .SYNOPSIS\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Generates a report from multiple XenDesktop sites showing desktops available.\n\u00a0\u00a0\u00a0 .DESCRIPTION\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Monitoring multiple sites can require multiple checks to ensure each is`\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 in proper running order.\u00a0 This script will determine the percentage of`\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 desktops available and display an HTML formatted table to provide an `\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 quick summary for an administrator.\n\u00a0\u00a0\u00a0 .PARAMETER SitesToMonitor\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A collection of strings with delivery controller addresses\n\u00a0\u00a0\u00a0 .PARAMETER WarningThreshold\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 When the value falls below this number, cells in the report will be highlighted\n\u00a0\u00a0\u00a0 .PARAMETER Interactive\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Enable this switch to load the file after generation\n\u00a0\u00a0\u00a0 .EXAMPLE\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 .\\CheckDesktopsAvailable.ps1 -SitesToMonitor \"site1.contoso.local\",\"site2.contoso.local\" -OutputPath \"C:\\temp\\report.html\"\n\u00a0\u00a0\u00a0 .EXAMPLE\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 .\\CheckDesktopsAvailable.ps1 -SitesToMonitor \"site1.contoso.local\",\"site2.contoso.local\"\u00a0 -OutputPath \"C:\\temp\\report.html\" -WarningThreshold 15 \n\u00a0\u00a0\u00a0 .EXAMPLE\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 .\\CheckDesktopsAvailable.ps1 -SitesToMonitor \"site1.contoso.local\",\"site2.contoso.local\"\u00a0 -OutputPath \"C:\\temp\\report.html\" -WarningThreshold 15 -Interactive\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \n\u00a0\u00a0\u00a0 .NOTES\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Author:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Preston Gallwas (functions credited)\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Twitter:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 @AtumVirt\n\u00a0\u00a0\u00a0 .LINK\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 http:\/\/www.atumvirt.com\n\u00a0\u00a0\u00a0 #>\n\n\n\u00a0\u00a0\u00a0 [CmdletBinding()]\n\u00a0\u00a0\u00a0 Param (\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 [Parameter(Mandatory,Position=0,ValueFromPipeline)]\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 [string[]]$SitesToMonitor,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 [Parameter(Mandatory,Position=1)]\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 [string]$OutputPath,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 [Parameter(Position=2)]\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 [int]$WarningThreshold=15,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 [Parameter(Position=3)]\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 [switch]$Interactive\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 )\n\nAsnp Citrix*\nFunction Set-AlternatingRows {\n\u00a0<#\n\u00a0.SYNOPSIS\n\u00a0\u00a0Simple function to alternate the row colors in an HTML table\n\u00a0.DESCRIPTION\n\u00a0\u00a0This function accepts pipeline input from ConvertTo-HTML or any\n\u00a0\u00a0string with HTML in it.\u00a0 It will then search for  and replace \n\u00a0\u00a0it with .\u00a0 With the combination of CSS it\n\u00a0\u00a0can set alternating colors on table rows.\n\u00a0\u00a0\n\u00a0\u00a0CSS requirements:\n\u00a0\u00a0.odd { background-color:#ffffff; }\n\u00a0\u00a0.even { background-color:#dddddd; }\n\u00a0\u00a0\n\u00a0\u00a0Classnames can be anything and are configurable when executing the\n\u00a0\u00a0function.\u00a0 Colors can, of course, be set to your preference.\n\u00a0\u00a0\n\u00a0\u00a0This function does not add CSS to your report, so you must provide\n\u00a0\u00a0the style sheet, typically part of the ConvertTo-HTML cmdlet using\n\u00a0\u00a0the -Head parameter.\n\u00a0.PARAMETER Line\n\u00a0\u00a0String containing the HTML line, typically piped in through the\n\u00a0\u00a0pipeline.\n\u00a0.PARAMETER CSSEvenClass\n\u00a0\u00a0Define which CSS class is your \"even\" row and color.\n\u00a0.PARAMETER CSSOddClass\n\u00a0\u00a0Define which CSS class is your \"odd\" row and color.\n\u00a0.EXAMPLE $Report | ConvertTo-HTML -Head $Header | Set-AlternateRows -CSSEvenClass even -CSSOddClass odd | Out-File HTMLReport.html\n\u00a0\n\u00a0\u00a0$Header can be defined with a here-string as:\n\u00a0\u00a0$Header = @\"\n\u00a0\u00a0