Application virtualization, IoT and Cloud Computing, Blog of Sacha Thomet

XenDesktop & XenApp FMA (7.x) HealthCheck – Oops!… I Did It Again

Some months ago I’ve created the Citrix PVS Health-Check Script which is a based on the idea and some parts of code from the Health-Check Script for XenApp 6.x of Jason Poyer ( .
Because now XenApp 7 with the Release 7.6 is finally in a state where considering an upgrade of the 6.x farms make sense, I belief that the demand for a XenApp 7.x Health Check Script grows.

So I did it again and took the “HealthCheck framework” to build a new version which combines the Power of the Citrix PS-Snappins for XenDesktop/XenApp and  the HTML-Output-Script of the existing HealthCheck Scripts.

The result is a new HealthCheck Script which is usable for XenApp and XenDesktop 7.x and what makes me also happy, with only a few line of more code the Script is downwardly compatible for XenDesktop 5.6 environments.

  XenDesktop XenApp Health Check HTML Output

This is just the first version and I’m sure that more check’s need to be added. Feedback and “Feature requests” are welcome … And to be honest I have not yet a big environment to test my Script, so please be insightfully if you find some bugs and report them to me.

In the first part of the Script you are able to configure some parameters. You can decide if you only want to see the “bad” Desktops on which something it’s going wrong or if you want see everything. In huge XenDesktop environments you want definitely only see the bad machines …  ( $ShowOnlyErrorVDI = 1 ) Also you can decide if you want only report XenApp or only XenDesktop or both. The Desktops and XenApps are in two different Tables. It’s also possible to exclude Collections ($ExcludeCatalogs) from the Check, so virtual Desktops which are for testing purposes are not checked.



If you have a feature request or a bug report please post it direct on GitHub.

Update 12.05.2016 (Version 0.95):
– Check CPU, Memory and C: of Controllers
– XenApp: Add values: CPU & Memory and Disk Usage
– XenApp: Option to toggle on/off to show Connected Users
– XenApp: DesktopFree set to N/A because not relevant
If you need a Health Check Script for XenApp Version which are older than XenApp 7.x see where it’s an excellent work and the inspiration for my HealthCheck-Scripts!

The code is on GitHub:

For Bug Reports or feature Request please use GitHub, of course you can also contribute on this code!

304 Responses to XenDesktop & XenApp FMA (7.x) HealthCheck – Oops!… I Did It Again

  • What’s your path were the Script is? It has maybe a blank inside?

    • I am running into an issue running this on a XenApp 7.12 environment. It will not gather the XenApp Server information or add it into the report even though the flag in the config file is set to 1.
      I am a full Xenapp and local administrator on all machines. Running powershell Ver4 Same failure if performed command line or via ISE

      Error 1

      At C:pscriptsFarmHealthReportXA-and-XD-HealthCheck.ps1:80 char:26
      + If ($CreateVariable) { New-Variable -Name $_.Name -Value $VarValue -Scope $_.S …
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : WriteError: (ShowXenAppTable:String) [New-Variable], SessionStateUnauthorizedAccessExcep

      Error 2

      The variable ‘$ShowXenAppTable’ cannot be retrieved because it has not been set.
      At C:pscriptsFarmHealthReportXA-and-XD-HealthCheck.ps1:987 char:4
      + if($ShowXenAppTable -eq 1 ) {
      + ~~~~~~~~~~~~~~~~
      + CategoryInfo : InvalidOperation: (ShowXenAppTable:String) [], RuntimeException
      + FullyQualifiedErrorId : VariableIsUndefined

      Error 3

      The variable ‘$ShowXenAppTable’ cannot be retrieved because it has not been set.
      At C:pscriptsFarmHealthReportXA-and-XD-HealthCheck.ps1:1264 char:5
      + if ($ShowXenAppTable -eq 1 ) {
      + ~~~~~~~~~~~~~~~~
      + CategoryInfo : InvalidOperation: (ShowXenAppTable:String) [], RuntimeException
      + FullyQualifiedErrorId : VariableIsUndefined

      • does the XML exists at the right place? Are variables filled in the XML?

        • Yes the xml file exists in the same directory as the script and the flags are set

        • I was able to identify the source of the issue. I had an errant Unicode character in the xml file from when I was editing.

          • Great – sorry that I wasn’t a help. But happy that it works now.

        • 1 enhancement that would be highly beneficial would be a column for calculation of % of disk space free. Color coded with the parameters for Alert and Critical in the configuration file.

      • Hi,
        I have both environment with two different sites (XA7.12 & XD7.12). I have provided both delivery controllers XA&XD and also set the value 1 for XA and XD table , but it is giving the information for one site only either XA or XD. I am looking for single consolidated report as shown above, Can you please help me to fix this. Enclosing the parameters below which I have provided in xml file. Thanks a lot.




        • This script is intended to create consolidated reports, it should work fine. Please send me your XML to my address [email protected] the name you know from the blog 🙂

        • please try the fixed version 1.28 (please see that it’s also a update in the XML)

          • Hi Sacha,

            Some of the VDA vdisk is on E: and some on F:, how do I make the script to capture vDisk info other than D: drive?

            Many thanks,

          • that’s currently not possible with the Script, you can change it to E or F. But the script currenktly is intended to have only one unique letter for the write cache.

        • please try the fixed version 1.28 (please see that it’s also a update in the XML)

  • Awesome Sebastiaan, Thank’s – I’ve just uploaded your improved version!

  • Great script Sacha!

  • Hey Sacha!

    I do have one pretty important addition to the Health Check script!
    You should add one more column to the VDA list (and to the Assignment table) that shows Maintenance Mode Enabled!!

    I just had a major outage at one of my customers where even though hundreds of desktops were Registered and unused, nobody could launch desktops because all desktops automatically went into Maintenance mode ….. without anyone noticing .. 🙁


    • Hey Christoph,

      Nice to read a comment from you in my Blog.
      I have already the column in the XenApp part added by Sebastiaan Brozius. Thanks for the hint, I will also add a column in the VDA section and the Assignment table.

      Cheers, Sacha

      • I’ll take it on my list for FeatureRequests and try to implement it in a future version.

  • Hi Raj, I am Sacha 🙂 you don’t need an SDK, its just PowerShell. I work with notepad++ to developp my scripts.

  • Hey Sacha,
    I got it. Thanks!!

  • That’s possible. I will have a look on the next version of the Script. Thanks for your Input Luis!

  • It should run on the DDC, no idea why you get this error. Do you run it as admin? Has the user who run the script write access in this folder?

    Btw: Check also my PVS HealthCheck Script.

  • Thank you for the quick reply!

    I am running it on a DDC- I am running PS as admin and my creds are Domain Admin. I have local admin on all enterpris servers, as well.

    I have seen your PVS script as well- nice work :). I’ll be looking at that next-

    This is what I pasted into my file (less specifics). Does the formatting look alright to you?

  • Thank you, Sacha! I’ll give that a shot and let you know- thanks a ton!

  • Great Script – thank you

  • Awesome post and script.

  • Sacha, any reason for not seeing the Spooler and the CitrixPrint column?

    • Hi Rajen, under XenApp both should be visible, under XenDesktop those columns doesent exist.
      If it doesent work there is maybe a issue with the connection between the script runs and the destination (firewall), it’s a Get-Service request:

      ———– snap ————————————–

      # Check services
      $services = Get-Service -Computer $machineDNS

      if (($services | ? {$_.Name -eq “Spooler”}).Status -Match “Running”) {
      “SPOOLER service running…” | LogMe
      $tests.Spooler = “SUCCESS”,”Success”
      else {
      “SPOOLER service stopped” | LogMe -display -error
      $tests.Spooler = “ERROR”,”Error”

      if (($services | ? {$_.Name -eq “cpsvc”}).Status -Match “Running”) {
      “Citrix Print Manager service running…” | LogMe
      $tests.CitrixPrint = “SUCCESS”,”Success”
      else {
      “Citrix Print Manager service stopped” | LogMe -display -error
      $tests.CitrixPrint = “ERROR”,”Error”

      ———– snap ————————————–


  • Hi Sacha,

    Realy awesome script and job, for our 15 customers “Farms” i integrated in scom with scheduled tasks.

    The exclusion for machine catalogs not working for me in xendesktop 5.6/7.5 and 7.6, any idea? the log says nothing, just check catalag### (all)

    # Example: $ExcludedCatalogs = @(“Windows 7″,”Windows 8 Test”)

    $ExcludedCatalogs = @(“LevXDMASTER”,”LevXAMaster”,”LevXAMaster”)

    • Just checked, for me in 7.6 it still works fine. Be carefull it’s in the current version only possible to exclude MaschineCatalogs, not DeliveryGroups!

  • Could you explain “desktops free column”?

    The script is great but I do not understand the value of this field?

    #5th column, DesktopFree
    $AssigmentDesktopsFree = $AssigmentDesktopsAvailable – $AssigmentDesktopsInUse

    • If you have e.g. 50 pooled VDIs and there are 14 in use, you can see that you have 36 Free desktops. Guess this feature is only relevant for pooled desktops – maybe I need to filter out dedicated desktops in the next version.

      • Yes, good point. My XD Sites (3 separate data centers) are using dedicated desktops. Our XD sites are mixing Pooled PVS and Dedicated.

        • In the same delivery group??

          • Sorry typo
            XD Sites in 3 Data Centers with dedicated desktops in unique Catalogs and Delivery Groups.

            XA has 3 Data Centers with Unique Catalogs for Pooled and Others

      • Thank you for this script Sacha, it’s really useful. In my environment the script seems to not detect the shared XenApp desktops correctly, so the ‘DesktopsFree’ column in DeliveryGroup check is showing a negative number instead of ‘N/A (XenApp)’ as shown in your example. Any ideas why this would happen?


  • Check the Version 0.9 – I’ve made some corrections.

  • Hi Sacha,

    can you please suggest or modify the script and add the below command in script so it will give the unique user session

    get-brokersession -maxrecordcount xxxx | select-object -property username

    Appreciated the script it is awesome.

    • Hi Majeed Attar, thank you for your comment. Where do you mean, guess in XenApp section. But I don’t have this Get-BrokerSession code.

      I’m just doing:

      # Column ActiveSessions
      $ActiveSessions = $XAmachine | %{ $_.SessionCount }
      “Active Sessions: $ActiveSessions” | LogMe -display -progress
      $tests.ActiveSessions = “NEUTRAL”, $ActiveSessions

      • Hi Sacha,

        I know you do not have this Get-BrokerSession in Script…I want to add this in script so it will provide the user sessions, Can this be possible to add in scirpt

    • I just checked again your “FeatureRequest” but what acutal you want to get from Get-BrokerSession | Select-Object -Property UserName – you wish a list of all current connected users in XenApp and the one conencted user on XenDesktop? This is a very dynamic data and I’m not sure if I need to add this in a HealthCheck-Script because the logged-on user name is not impacting the health of a server. Or do I missunderstand your request?

      • We use xenapp and has published Desktop as if i run this command on Delivery controller it give me the output with user id and also shows if user has 2 session or not..

        We need that we are planning to run this script twice or thrice in a day…

        • I will have a look what I can do.

        • Majeed Attar I really want to help you and to fulfill your requirements, but currently it’s still a bit fuzzy what you need. Can you specify more exact your request. Do you wish to know the users of the single server or of the farm? What’s the intention for this information, do you want to know if you have an issue with session sharing? So I need only to output the dublicate sessions in a unique delivery group?

          Just to create a table with all logged on users will not be helpful in a health-check script. Consider that this script need to fulfill requirements of small and very large farms – so I need to have a usefull information at a glance even on a farm with 20’000 logged on users.

          • Hello Sacha,

            Thanks for the reply..

            Actually i need to get the current connected user of farm. so i can see how many of the user have duplicate session so it will easy for us to troubleshoot further as we are facing the issue that some random users are not able to connect on first attempt.. some time user has disconnected session and they try to connect but failed to do same..

          • Hi Majeed,

            I believe you should setup an OData API feed from Director. I don’t believe Sacha’s script is the place for this.


        • So a new table with this single information will be enough for you? No relation to a Server or Desktop?

          • yes.. that will be enough for now..and will be most appreciated.. 🙂

  • Hey Sacha,

    Thanks for the updated version – this script is just awesome!

    Not sure if this is a typo or I am reading it wrong

    Line 68: # Set to 1 if you want to Check a Environment with XenApp (5.x)

    I think that should read something like “Check Virtual Desktop”


  • I would love to see
    DiskFree C
    DiskFree D
    if a WMI request will result in an answer.

  • Hi Sacha, your Script is great as I have used it. To get more details of Xendesktop infrastructure, did you update this script in latest version? If yes, may I have that script?

    Thanks, Ravi

    • Sorry no newer Version currently – I have always the newest version online. But no alway time to create new versions.

  • aaaaaAAAAwsome script….

  • Sacha,
    Awesome script, really appreciate the work. I have one question about the “serverload” section, all the columns are showing up red no matter what value is in it, (0,40,80,160,200,240,280, etc.) any ideas? Some machines have only 1 user on it and still shows red.

  • Sacha,
    With version 0.93 of the script the email does not send when using more than one email address. It works fine with just one address, but if you add more addresses the mail never sends. This worked fine in version 0.92.

  • What are the chances you could add a variable to sends an email only if an error/warning is detected some where in the process? I did something like this on the older one because the people I worked with didn’t really care for the spam since our uptime was about 90%.

    • Hi, this is something what it’s planed in a future release for both of my health check scripts (XA/XD and PVS), but need a bit time to implement and test. But it’s definitely on my todo list, but not with highest priority to be honest.

  • Sacha, how can I get the total session count and have it displayed on top somewhere?

  • Having an issue running this against a XA and XD environment. It runs successfully against either independently, but both are placed into $DeliveryControllers the test only completes for the first entry regardless of ordering.
    Is this by design? When I looked at the script it seemed to be written to evaluate more than one controller in series.

    Example: $DeliveryControllers = @(“XA-CTRL1″,”XD-CTRL1”) produce results only for XA-CTRL1 while $DeliveryControllers = @(“XD-CTRL1″,”XA-CTRL1”) yields results only for XD-CTRL1
    log just shows:
    Check virtual Desktops ####################################################################################
    Check XenApp Servers ####################################################################################
    Machine: ………………………………….

    for now ill just run it independently against each environment , but it be great to have just one report.
    Any ideas?

    Also in testing I found adding $FileName.Close to end of “Function writeHtmlFooter” prevents the result .htm file from being locked.
    , so when testing code changes you can modify the code and rerun without having to manually kill the file lock or restart PowerShell.

    Great Script, Thanks for posting !!!

    • Hi Jess, thanks for using my script and for the feedback. The script intends to run on one farm. Do you have 2 separated delivery controllers in 2 farms? So you need run the script for each farm. The possibility to use more than one delivery controller is just in case the first DeliveryController does not respond.

      Usually if only one instance of the script runs I have never a file lock. But I’ll doublecheck this again.

    • Try to enter localhost in delivery controller variable and run it on the DeliveryController.,

  • hi – superb script.

    I have a multisite Xendesktop 76 implementation and like to be able to use this script to check all the sites at 1 go. is that possible?

  • Sacha,

    Any chance you have a way to toggle the top 3 sections on/off? I want a version that just has the list of servers and not the top 3 sections…is there a way to comment them out?

    • In the current version not, you need to comment out the lines. I’m working on a future version of the script (first pvs, later XenDesktop/XenApp) in which I work with functions for the checks where it will be much easier to opt-in/opt-out the checks.

      • Hi SachaKen Donaberger

        Dont know if it is my place to reply but I have cut a few things out the script to monitor load which is send every hour
        Columns used as follows
        ServerName CatalogName ServerLoad Ping MaintenanceMode Uptime RegistrationState ActiveSessions DesktopGroupName WindowsConnectionSettings(LogonEnabledLogonDisabled


  • Hi.
    Great script as usual. I have used this and the older Version for my 6.5 farm for a long time now.

    Against XenDesktop Pool 7.6 everything Works fine, but when running against XenApp 7.7 i’ve got an error.

    Get-BrokerMachine : An error occurred while receiving the HTTP response to
    okerAdminService/v2. This could be due to the service endpoint binding not using the HTTP protocol. This could also be
    due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server log
    for more details.
    At C:TempxsXA-and-XD-HealthCheck.ps1:534 char:13
    + $machines = Get-BrokerMachine -MaxRecordCount $maxmachines -AdminAddress $AdminA …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Get-BrokerMachine], SdkOperationException
    + FullyQualifiedErrorId : Citrix.XDPowerShell.Broker.UnexpectedException,Citrix.Broker.Admin.SDK.GetBrokerMachineC

    What am I missing? I’m running the script localy from a XA 7.7 Controller.

    • Hi Anders, I just tested on my XenDesktop 7.7 farm what is virtually the same like XenApp 7.7 … it works fine. Does your delivery controller has a problem, can you try on a second one?

  • Hi Sacha

    Your PVS Script gave me needed brownie points at work but can you help me with the following error I am getting

    At C:XA-and-XD-HealthCheck.ps1:77 char:185
    + …”, )
    + ~
    Missing expression after ‘,’.
    + CategoryInfo : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : MissingExpressionAfterToken

    Any ideas for me please

  • Hi Sacha

    I have added some columns to the Xenapp Checks like Multisession and LogonEnabled or LogonDisabled

    This has probably been done already but just putting it out there


  • Hi Sacha

    I have added some columns to the Xenapp Checks like SessionSupport and LogonEnabled or LogonDisabled

    This has probably been done already but just putting it out there


  • Hi Sacha, thank you for the wonderful script. Also, I’m looking for Citrix Presentation Server 4.0 Health Check script. If you have anyone.. plz share..

    • Hi GP, thanks for your feedback. That’s not so easy, you don’t have powershell, XenApp commands are availible from XA5.x, what do you exaclty need? Maybe I can help you but I’ll not invest time for legacy version scripts.

      • Sacha, I’m looking for the same health check script for legacy environment… I’ve powershell 2.0 but, .NET framework like that few plugins are missing and I’m not recommend to upgrade those… so, planning to do with the vb script in legacy envt to get the health check report. I’ve tried few examples which was shown in online.. but, couldn’t worked for me…

        Plz help me on this

  • Hi Sacha, thank you so much for the wonderful script. I love it.

    Quick question, can you kindly add the addition to the script to shown:

    1. Number of Active Users per XenApp Server
    2. WMI
    3. XML
    4. Available Disk Space
    5. AvgCPU Usage

    Thank you, and keep up the great work Sacha.


    • Hello Bernhard,

      Thank you for your Feedback.

      1. Number of Active Users per XenApp Server -> can I do, will I do in a later version.
      2. WMI -> if WMI doesen’t work you have errors e.g. with the uptime, you will notice that.
      3. XML -> What do you meant with XML?? In XA7 the workers are no more XML-Broker if you mean that back from old IMA-Archtitecuter XenApp
      4. Available Disk Space => possible, only C: should be enough otherwise you are unlimited in configuration …
      5. AvgCPU Usage => not so easy… in which timeframe, nearly unlimited in configuration …


    • Hello Bernard, I have implemented some of your wishes in the new Version 0.95

  • Sacha,
    I’m looking for a powershell script which generate a entire farm inventory list… if yes, please help me on this…

  • Hi Sacha,
    Thanks for the very useful script…… I’m trying to figure out how to remove the “ConnectedUserName” column from the summary. Also, as previously requested, add average CPU and MEM utilization per server just like in the script for XA 6.5. Could this be done?


    • I’ll do an update with the new requests, but currently I’m very busy … please be patient .. sorry for that.

    • Hi Raul, I have implemented a Switch for this in the new Version 0.95

  • Sacha (and other contributers to this script): many thanks for this amazing script!

    As stated by Bradley earlier, the DesktopFree column for XenApp shows a negative number. In my opinion the DesktopFree isn’t relevant for Shared Desktop environments. Can this being changed in a next release?

    • It’s fixed in the new Version 0.95

      • Sacha,
        Thank you so much for this script, been running 0.93 for the past year everyday and it’s a life saver.

        I tried using 0.95 today and I get the following error in red:

        At C:CustomPowerShellXA-and-XD-HealthCheck.ps1:608 char:178
        + … ntDesktopsFree “DesktopsFree > 0 ! ($AssigmentDesktopsFree)” | LogMe -display -p …
        + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Unexpected token ‘”DesktopsFree > 0 ! ($AssigmentDesktopsFree)”‘ in expression or statement.
        + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
        + FullyQualifiedErrorId : UnexpectedToken

      • ok, found the issue……

        the following script option only has 953 lines of code:
        You can click here to see the Script code …

        the script you can click to download the file has 976 lines of code, so something is missing from the “You can click here to see the Script code …” option.

  • Sacha,
    Great update on the script!!!! Can you add an option to enable or disable DFreespace on the ControllerServers and the XenApp-Server/XenDesktop-Server?

    • Of course, I’ll add it in a further version, you have a server with only a C? Will the D be red? you can comment out in the table definition as workaround.

      • I do not have a server with only a c drive, my server at least have a c: and d: drive. I guess an option to disable the DFreespace is really not applicable or needed from my stand point.

        • Ah sorry I didn’t understood, but just had a look in my code and I just realized that I have not yet a D: check.
          You like that I add the D:, right?

        • Ryan – if you don’t mind can you add this also as an Issue in GitHub – so we can be sure that’s tracked and you get notified as soon it’s implemented

  • Hi Sacha,
    Well done on the CTP and the site in general, very useful.

    Is there any scope for a Storefront Health Check feature. Either as a bolt on to the XDXA script or as a separate scrip.
    Thanks Tony

    • I like the idea, what is better a separate Script or integrated in the XenApp Health Check script? I just set up a Twitter poll:

      • Great Sacha,
        Can the script interrogate remote storefront servers, as well as the local server/server group.
        Maybe an array of variables that can hold a list of server names?

        • Curretntly I started with the idea that it runs on a SF server, but you can launch it with a Remote session. First start relally early beta is here: What checks are on your wishlist?

          • The basics really (to start!)
            -Disk space
            -Citrix Configuration Replication
            -Citrix Credential Wallet
            -Citrix Default Domain Services
            -Citrix Peer Resolution Services
            -Citrix Subscription service

            Nice to haves would be
            -Verify the Base URL is available
            -Verify managed Delivery Controllers are up
            -Version of Storefront installed
            -We have 14 Storefront servers, it would be nice to run a single script to capture all Storefront servers

  • Just to let you know I have added our Jdrive on the DDC’s and D Drive on the Xenapp servers as well

  • Sorry just the J Drive on the DDC’s

  • Hi,

    We’ve got a strange issue today : one of our XenApp host was unable to accept new user connection. The server itself was Registered, Ping and able to accept/launch session but the Receiver stuck at “Local Session Manager”. So, after looking more deeply in the XenApp and XenDesktop 7.6 Farm Report we found a server that Ping, was Registered and had a Load Index @ 5000 but no user logged in (no user in the column “Connected Users”). The DDC send all the new connection to that server because it has the less load on it. We need to put this server in maintenance to resolve the strange issue.

    So, can you add a something like a validation in your report script so if a XenApp host is Registered, Ping and had a Load Index > 1000, highlight the line in red or something like that? It can probably help other people to be proactive.


    • This is already in:

      # Set value for a load of a XenApp server that is be fine, but is needed to escalate
      $loadIndexWarning = 800
      # Set value for a load of a XenApp server that is be critical
      $loadIndexError = 1500

      Which value you set here – did the server remain in green even when he has breached the set load index.

      • I forgot to say the fourth critaria who is probably needed for our case : Connected User = 0 (no user in the list, Get-BrokerSession)

        So, put in red when a XenApp Host is Registered, Ping, Load Index > 100 and Connected User = 0

        I hope you understand my need.


        • The current construct don’t consider dependencies, sorry. I will maybe implement this in a future release, but there are still a bunch of other requested features in the FR-Queue on GitHub

  • Should I add the FR on GitHub? Thanks yor the quick reply.

    • If you have a GitHub account anyway then yes please – so I have all request on the same place.

  • We just started using some of these scripts and have found them very useful. Could these two items be added?
    *Get-BrokerMachine -PowerState Unknown
    *Get-BrokerHypervisorConnection – State InMaintenanceMode or Unavailable or Unknown
    If these currently exist in one of the scripts, perhaps I am missing it.
    Best Regards.

  • What u have considered for ServerLoad value for XenApp Servers.

    How it is getting calculated

  • Sachan,

    Thanks for your wonderful script. It’s awesome.
    Is there a way to ran the same script for the multiple farms? I’ve 6 farms in our envt and need to manually log into all the farms and check the health. Please help us on this.. one script can ran for multiple farms and get an output.

    Appreciate if anyone can help us.

  • Thank you so much for the script, it works great. Have one question. Uptime for DDC still shows green color even if uptime is more than 2 days. I tried changing the values in xml file for minUpTimeDaysDDC. Is that how it is designed?

    • It’s minUptime and stand for Minumum, it’s to see that a DDC was rebootet. In my point of view it’s not a Problem to have a DDC running many days, the Script show you in a highlighted way when a DDC was rebooted.

      • I understand, Anyway we used reboot delivery controllers in alternate days. i found where to tweak in script to get that. thank you so much. really appreciate your effort.

  • hi can someone please help me out to set up this script for my xa xd farm , i have an xa and xd farm using mcs each with 3 delivery controllers each

    • What’s the problem? Just update the XML according your config and run the script.

      • my questions are i dont use pvs so what do i do with those parameters, delte ?,i run it from my delivery controllers?, on each site?, i have to all delivery controllers for each site inside same script or i have to do it sepratelly,i saw xenapp and xendesktop options so i cant run one script for the 2 farms?

        • This script is not PVS related, it has some checks which are Valid for PVS, but don’t care about. It run on your Delivery Controller. You you have a mixed farm with XA/XD just run in once, otherwise 2 checks are needed. Just run the Script on the according DeliveryController. Just try, if you stuck then shout and I will see how I can help you.

    • If you have two farm, you need to setup it two times.

  • Hi , I’m had a quick look on XA-and-XD-HealthCheck.ps1 to replace with existing XenAppServerHealthCheck_XDA7_v1.8.ps1, found the new XA and XD healthcheck is wonderful, but missing the WMI check, XML check, Logons, CTXAgent, ICAPort, CGPPort, vDisk and License status, Storefront status. Can someone help me incorporating the above requirement in a new XA-and-XD-HealthCheck.ps1 script.

    • Guess that’s not the same check, we are on V 1.2.2 and never had 1.8, also no License Status und StoreFront status. Sorry. Who is the author of your XenAppServerHealthCheck_XDA7_v1.8.ps1?

  • I managed to get the service state now, also seems DFreespace if condition need to be corrected (I corrected myself replacing the CFreespace with DFreespace ). sorry for the confusion its the same old deptive script v2 I renames as 1.8.

    • This is true, I had to change the lines in the section starting on line 1094 to the following:

      If ( [int] $XAPercentageDSd -gt 15) { “D: Disk Free is normal [ $XAPercentageDSd % ]” | LogMe -display; $tests.DFreespace = “SUCCESS”, “$frSpaced GB” }
      ElseIf ([int] $XAPercentageDSd -eq 0) { “D: Disk Free test failed” | LogMe -error; $tests.DFreespace = “ERROR”, “Err” }
      ElseIf ([int] $XAPercentageDSd -lt 5) { “D: Disk Free is Critical [ $XAPercentageDSd % ]” | LogMe -error; $tests.DFreespace = “ERROR”, “$frSpaced GB” }
      ElseIf ([int] $XAPercentageDSd -lt 15) { “D: Disk Free is Low [ $XAPercentageDSd % ]” | LogMe -warning; $tests.DFreespace = “WARNING”, “$frSpaced GB” }
      Else { “D: Disk Free is Critical [ $XAPercentageDSd % ]” | LogMe -error; $tests.DFreespace = “ERROR”, “$frSpaced GB” }

  • Is there a way to strip the domain and just have the hostname in the table of results for Citrix Controllers health.

    • should not be so hard, try this:


      # Column Name of Desktop
      $machineDNS = $machine | %{ $_.DNSName }
      “Machine: $machineDNS” | LogMe -display -progress


      # Column Name of Desktop
      $machineDNS = $machine | %{ $_.DNSName }
      “Machine: $machine” | LogMe -display -progress

  • It is possible, to Display only the unregistered/failure/TimedOut XenAppServer ?

  • Is it possible to include license status and utilization?

  • His there a way to ass more then 1 adress of the recipient

    [email protected]

  • How do I put localhost in the XML file, sorry I not up to speed on the code? Thank you

  • I’m able to get the report showing Controller server, Catalog name, Delivery group info. However i’m not able to get any info for XenApp servers.
    Could you please help?

    The variable ‘$ShowXenAppTable’ cannot be retrieved because it has not been set.
    At C:UsersxxxxxxxDesktopXA-and-XD-HealthCheck-masterXA-and-XD-HealthCheck.ps1:983 char:4
    + if($ShowXenAppTable -eq 1 ) {
    + ~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (ShowXenAppTable:String) [], RuntimeException
    + FullyQualifiedErrorId : VariableIsUndefined

    ####################### Check END ####################################################################################
    The variable ‘$EnvironmentName’ cannot be retrieved because it has not been set.
    At C:UsersxxxxxxxDesktopXA-and-XD-HealthCheck-masterXA-and-XD-HealthCheck.ps1:1237 char:21
    + $EnvironmentName = “$EnvironmentName $XDVersion”
    + ~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (EnvironmentName:String) [], RuntimeException
    + FullyQualifiedErrorId : VariableIsUndefined

    Saving results to html report: C:UsersxxxxxxxDesktopXA-and-XD-HealthCheck-masterCTXXDHealthCheck.htm
    The variable ‘$ShowXenAppTable’ cannot be retrieved because it has not been set.
    At C:Usersadmin-nguyenldDesktopXA-and-XD-HealthCheck-masterXA-and-XD-HealthCheck.ps1:1260 char:5
    + if ($ShowXenAppTable -eq 1 ) {
    + ~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (ShowXenAppTable:String) [], RuntimeException
    + FullyQualifiedErrorId : VariableIsUndefined

  • I have it set to 1

    • when you set it to 0 you have still the error? seams there is something wrong from take the variables from the xml to the script, but all others seems to be working

  • here’s the log

    Check virtual Desktops ####################################################################################

    Desktop Check skipped because ShowDesktopTable = 0
    Check XenApp Servers ####################################################################################

    ####################### Check END ####################################################################################

  • great script. thank you so much. I’m having a similar issue Kevin was having, it seems as if, the xml variables are not being properly integrated with the script.

    New-Variable : Cannot overwrite variable EnvironmentName because the variable has been optimized. Try using the
    New-Variable or Set-Variable cmdlet (without any aliases), or dot-source the command that you are using to set the
    At C:XA-and-XD-HealthCheck-masterXA-and-XD-HealthCheck.ps1:76 char:26
    + If ($CreateVariable) { New-Variable -Name $_.Name -Value $VarValue -Scope $_.S …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : WriteError: (EnvironmentName:String) [New-Variable], SessionStateUnauthorizedAccessExcep
    + FullyQualifiedErrorId : VariableNotWritableRare,Microsoft.PowerShell.Commands.NewVariableCommand

    New-Variable : Cannot overwrite variable ShowXenAppTable because the variable has been optimized. Try using the
    New-Variable or Set-Variable cmdlet (without any aliases), or dot-source the command that you are using to set the
    At C:XA-and-XD-HealthCheck-masterXA-and-XD-HealthCheck.ps1:76 char:26
    + If ($CreateVariable) { New-Variable -Name $_.Name -Value $VarValue -Scope $_.S …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : WriteError: (ShowXenAppTable:String) [New-Variable], SessionStateUnauthorizedAccessExcep
    + FullyQualifiedErrorId : VariableNotWritableRare,Microsoft.PowerShell.Commands.NewVariableCommand

    New-Variable : Cannot overwrite variable PvsWriteMaxSize because the variable has been optimized. Try using the
    New-Variable or Set-Variable cmdlet (without any aliases), or dot-source the command that you are using to set the
    At C:XA-and-XD-HealthCheck-masterXA-and-XD-HealthCheck.ps1:76 char:26
    + If ($CreateVariable) { New-Variable -Name $_.Name -Value $VarValue -Scope $_.S …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : WriteError: (PvsWriteMaxSize:String) [New-Variable], SessionStateUnauthorizedAccessExcep
    + FullyQualifiedErrorId : VariableNotWritableRare,Microsoft.PowerShell.Commands.NewVariableCommand

    The variable ‘$PvsWriteMaxSize’ cannot be retrieved because it has not been set.
    At C:XA-and-XD-HealthCheck-masterXA-and-XD-HealthCheck.ps1:83 char:20
    + $PvsWriteMaxSize = $PvsWriteMaxSize * 1Gb
    + ~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (PvsWriteMaxSize:String) [], RuntimeException
    + FullyQualifiedErrorId : VariableIsUndefined

  • another thing to note. when I use Powershell ISE, it works fine. I’m using version 4.

    • Carlo, there is a new version out you might try that but I’m not certain your issue is fixed in it. If it’s still not working on the new release go to the github link on Sacha’s site and look at the bug list. I found a temp fix for your issue that I’m using right now that I posted out there. You basically define two variables for the XML location and path and it starts working outside ISE.

      • I can confirm that both 1.2.3 and 1.2.4 DOES NOT run correctly with a Scheduled Task. My signature in the email isn’t correct, nor the body of the email. It is missing all the target device information. If I open it up in PowerShell ISE and hit the play button everything works as expected. Again, this stopped working in both 1.2.3 and 1.2.4.

        1.2.3 works just fine.

        • I have 1.2.3 and 1.2.4 as scheduled task working fine 🙁

        • What OS? Which PoSh-Version, Which XA/XD Version you are using? How do you call the Script as Scheduled task? Powershell.exe with the Script as an argument?

          • What OS?
            Server 2012 R2

            Which PoSh-Version

            Which XA/XD Version you are using?

            How do you call the Script as Scheduled task? Powershell.exe with the Script as an argument?
            Calling it with an action:

            Add arguments (options):

            Again, nothing above has changed other than the new ps1 script between 1.2.2 to 1.2.3 or 1.2.4

          • We will check, for me and for Stefan it’s working. with 1.2.3 this new maint mode functionality was implemented.

          • Hi Sacha, I have the same issue 1.2.4 works with I manually run in PowerShell ISE but not when used with scheduled task. 1.1.0 was working fine before.

  • Hi Sacha/Ryan, I fixed this issue by running the scheduled task with argument “non interactive”

    I used below command in argument field after which it started working like we run from ISE.

    -NonInteractive -file C:taskXA-and-XD-HealthCheck.ps1

    • Sri,
      Thank you soooo much, that worked for me as well, going to change all my tasks to this.

  • a fantastic script..

  • Hi Sacha,

    Is it possible to filter the server that will be excluded from health check? The catalog exclusion is not possible because multiple servers are on the same catalog where one of the server need to be excluded from the health check.

    • All is possible – just programming effort. I think to add this feature managed by Tag’s, you can Add a Tag “noHealthCheck” in Studio and the Server/Desktop will be excluded – would this help?

  • Hi Sacha

    This script is amazing. One issue I am having though is that the Ping function is reporting erroneous failures. I can ping the machines from the same server I run the script on, so I’m thinking perhaps it is overloading itself by starting so many ping objects? I get similar issues with the power state check showing machines as “unknown”. Any suggestions?

    • Here it’s working, do you have long response times? Maybe a parnoid security config and user which runs the script is not allowed to ping?

      • Hi Sacha

        looks like our DNS is on the fritz. thanks for getting back so quickly. The script works as intended, it seems!

        anything I can do about the power states coming back as unknown? I’m not sure where in the script this is all handled so if you could point me to the right area, I can teach myself how it works and hopefully troubleshoot our issues

        • Have you looked in Citrix Studio? Does it show Unknown in Studio?

          • Aye, that will be it. Cheers. I wasn’t sure how the information was being gathered, completely forgot about it being a field in studio!

          • Reboot your delivery controllers one by one and it will clear up the unknown state. You are on 7.6 right?

  • No matter what I try I keep getting this error
    The variable ‘$hostinvocation’ cannot be retrieved because it has not been set.

  • Hi Sacha,
    Thanks for great Script.
    Can we add the values related to Hosting connection like it will check the Host connection and if all well shows green with OK.
    And details related to Administrators/Roles and SCope to check wheter there is any new roles created or not.

    • Plus it didn’t contain anything about the new feature Appdisk

    • I’m not sure if I understand 100% what you mean, but Yes please feel free to contribute on the project in GitHub, Hosting in already in.

  • Hi Sacha,
    Excellent script and the output is very neat and easy to read.
    I am trying to adapt the script so that I can run other health checks against other infrastructure systems and produce a html file with the relevant data.
    Would you be able to describe the basics of what variables, arrays and hashtables I need to manipulate to change the information from Citrix focused to be almost technology agnostic?
    For example, I see you have create an empty *results hash, then do a Foreach on a number of items and they then have a couple of if statements, assuming to mark things as passed of failed or 20% sort of thing. and inside the Foreach statement you first create a $tests hash, but I am unsure how you get the properties such as $tests.AssignedToUser and $tests.NotToUserAssigned? Hope this makes sense and you are able to help!


  • Thanks for the Great Script
    Even running non interactive in scheduled task – NonInteractive -file C:\Scripts\XA-and-XD-HealthCheck.ps1
    I get blank results for – Uptime, Spooler, CitrixPrint, CFreespace
    Err – AvgCPU, MemUsg

    • Permission on farm? Firewall from location where script runs in the direction of the target?

  • Hello,
    This is an excellent script. it help me to get my daily Health check.

    I have a issue. i am having more thane 600+ XA and XD machines. to get the report script is taking more than 40 min.
    Is there any way to speedup the process.

    Thanks In advance.

  • Hi team,
    I recently upgraded from PVS 7.1 to 7.6 cu4 and the PS script stopped working.
    I attempted to re-register the McliPSSnapin, but get below error

    I am using .Net 4.7, PS version 2

    “Exception occurred while initializing the installation:
    System.BadImageFormatException: Could not load file or assembly ‘file:///C:\Program Files\Citrix\Provisioning Services C
    onsole\McliPSSnapIn.dll’ or one of its dependencies. This assembly is built by a runtime newer than the currently loaded
    runtime and cannot be loaded..”

    Any advise appreciated.

    • this is PVS not XA/XD, but re-register the snapin should help:

      “C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe” “C:\Program Files\Citrix\Provisioning Services Console\McliPSSnapIn.dll”

      • apologies – I will repost in correct forum. My issue is that the snapin will not re-register.

  • not sure what I am doing wrong. I put the username into the xml file. I than ran the two lines of code to generate the hash. The SMTP portion keeps error,

    XenApp Check skipped because ShowXenAppTable = 0 or Farm is

  • Hi

    Thanks for the nice script.

    I see that I get “Err” in AvgCPU used column. It is not on all the servers, but on few of the servers. What could be causing it to ERR out?

    • can you reach this server remotley from the machine where the script runs? (firewall, network, etc.)

  • Does XenApp 7.5 supports gMSA? I want to set this script in Scheduled Task running under gMSA.

  • Hi,

    We mentioned the catalogs to excluded however script is processing all the checklist and only skip it in the reports. Which is waste of execution time and been taking too long to get the result. How can we exclude the machines from the execution?


  • Thanks Sasha,
    please improve the script to send email only based on alarm threshold 🙂
    thanks for u job

  • In our XD 7.15 farm we have physical machines as well (desktops and blades). is there an adjustment to make to get the ping, uptime, regstats and display mode working on those

  • Hi sacha,

    i am not an expert in Powershell. in the XA and XD healthCheck.ps1 file. I am not able to find a way to enter the path under get-content to read the content of XML file. Could you please let me know where should i make the changes to add the path for this.

    # Import parameter file
    $Global:ParameterFile = $ScriptName + “_Parameters.xml”
    $Global:ParameterFilePath = $ScriptPath
    [xml]$cfg = Get-Content ($ParameterFilePath + “\” + $ParameterFile) # Read content of XML file

  • Sacha,

    Just wanted some input on the script. It has been running fine. The only issue I’ve run into as of late is it seems to stop or pause when it runs into a device that has WMI issues.
    Is there anything you can do to detect and bypass these types of errors?

    [ERROR] WMI connection failed – check WMI for corruption
    The property ‘VersionInfo’ cannot be found on this object. Verify that the property exists.
    At C:\Rob\XA-and-XD-HealthCheck-master\XA-and-XD-HealthCheck.ps1:1052 char:1
    + $MachineOSVersion = (Get-ItemProperty -Path “\\$machineDNS\C$\WINDOWS …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], PropertyNotFoundException
    + FullyQualifiedErrorId : PropertyNotFoundStrict

    • I have the same issue as Rob. My environment consists of ONLY windows 10 desktop OS.
      WMI connection failed – check WMI for corruption

      The only output is for DDCs.

      • Hi Sacha,

        Just wanted some input on the script. It has been running fine but getting VersionInfo error.

        Please suggest what could be the possibility of error.

        The property ‘VersionInfo’ cannot be found on this object. Verify that the property exists.
        At C:\Healthcheck\XA-and-XD-HealthCheck.ps1:1380 char:1
        + $MachineOSVersion = (Get-ItemProperty -Path “\\$machineDNS\C$\WINDOWS\System32\h …
        + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo : NotSpecified: (:) [], PropertyNotFoundException
        + FullyQualifiedErrorId : PropertyNotFoundStrict

        • which line of the script is that? It has been running fine, what did you change that the error occurs.

          • Hi Sacha, It showing error while executing machine OS Version and i did not change anything in the script file.

            Machine: Test06.ABC.COM
            Catalog: Test
            The property ‘VersionInfo’ cannot be found on this object. Verify that the property exists.
            At C:\Healthcheck\XA-and-XD-HealthCheck.ps1:1380 char:1
            + $MachineOSVersion = (Get-ItemProperty -Path “\\$machineDNS\C$\WINDOWS\System32\hal.dll…
            + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            + CategoryInfo : NotSpecified: (:) [], PropertyNotFoundException
            + FullyQualifiedErrorId : PropertyNotFoundStrict

            Serverload: 0
            MaintenanceMode: False
            State: Registered
            VDAVersion: 7.15.2000.291
            HostedOn: Hypervisor01
            Active Sessions: 0
            Connected users:
            DeliveryGroup: Test_Group
            CPU usage is normal [ 15.3 % ]
            Memory usage is normal [ 27 % ]
            Disk Free is normal [ 69.4 % ]
            Disk Free is normal [ 97.91 % ]

          • Is the Windows installed on C: ?

          • Sacha on 30/10/2018 at 10:20
            Is the Windows installed on C: ?

            Ravi- Yes OS is installed.

          • the file exists which the Script tries to read and the user which run’s the script has access to it?

          • Yes.. I have checked that.. user has permisson

          • Do you see anything in the eventlog?
            Go to the destination system and see with procmon why there cannot be accessed.

            Sorry cannot help more here, not a Bug on the Script. Permission issue in your Environment.

  • Hi,XA/XD 7.15.2000 Output file for License & Catalog does not populate


    • does that work:

      get-wmiobject -namespace "ROOT\CitrixLicensing" -computer YOURSERVER -query "select * from Citrix_GT_License_Pool"

  • Sacha, I am having difficulty to get the email part to work. we are using office 365.

    smtpenablessl = true
    smtpserverport = 587
    emailfrom= [email protected]
    emailto= [email protected]
    smtpUser= [email protected]

    This is the part which I am not sure what to put:
    smtpPW= mypassword

    what did I do wrong?

    • so you have this info in the XML right, did you encrypted your password? See XML File Comment:

  • Hi
    I have some question about this script.
    1.Is it require only DDC? it is not working on other citrix server.
    2.What kind of resource is use on server while script Running.

    • 1. Because of the FMA architecture it needs the DDC yes.
      2. It’s just tho PoSh snapin provided by Citrix – Memory&CPU depends of the size of the environment.

  • Has anyone tried this script on XenDesktp site hosted in Citrix Cloud? I haven’t tested much but by simply placing connector names in place of delivery controller did NOT work.

    • Hi Sacha, This script is fantastic! So far it has worked great. It seems like I ran across something in the script that is not running, I’m sure its something I’m doing wrong but I would like a column in xendesktop that shows the last time a VDI was used. We have a policy that allows us to reclaim a VDI if it hasn’t been used for >= 60 days. Is there something I can do to get this part of the script to work? Again, thanks so much for all the work you and Github do.

      • In Version 1.3.7 the functionality for the column “LastConnect” was added which shows the last connection over ICA. Does this address your request?

        • Yes, I see that column now! Thanks so much!

          • Oh, I forgot to mention that the report is running great but not sending the email with the html report. It used to work and I’m pretty sure I have not changed the XML file. Do you have any ideas why this may not be working? Thanks.

  • Ok, I figured out why the report was not sending but I have a new question. I have some Linux VDIs, specifically Ubuntu 16.04 and CentOS 7.5. During the running of the script these devices get errors referring to “The RPC server is unavailable” and “WMI connection failed”. These are looking in “\\$machineDNS\C$\Windows …” Linux obviously does not have this path. Is there a fix for this? Thanks.

  • Hi and thank you for your job!
    I try to make it work on a Windows 2016 server but I could not succeed, our PS version is 5.1.
    Do you think is possible to make it work?
    Thank you.

    • What error do you see?

      • Au caractère C:\temp\XA-and-XD-HealthCheck.ps1:147 : 190
        + … ata-ga-click=”(Logged out) Header, go to Features”>Features <span cla …
        + ~
        L’opérateur « →Case Studies <span cla …

        I have a lot of that errors, in english is something like "Ampersand not allowed. The & operator is reserved for future use…" and "<" it's the same.
        what do you think?
        Thank you.

      • Au caractère C:\temp\XA-and-XD-HealthCheck.ps1:160 : 243
        + … lick=”(Logged out) Header, go to Case studies”>Case Studies <span cla …
        + ~
        L’opérateur « →Security <span cla …
        + ~
        L’opérateur « →</s …
        + ~
        Le caractère perluète n’est pas autorisé. L’opérateur & est réservé à une utilisation future. Placez un caractère
        perluète entre guillemets doubles ("&") pour que ce symbole soit considéré comme une chaîne.

  • 7.15 CU3 Error loading XenApp Powershell snapin

    • more infos please …

      • Does it work in 7.15CU3 ? Do we need to update ask ? Currently we run in Citrix.Admin.V1.. V2?

        • Sdk**Not ask

        • there is no known general issue, I have one productive environment with 7.15 CU3 where check is running fine.

          • Following Error Occurs XML files in same location as script

            The variable ‘$EnvironmentNameOut’ cannot be retrieved because it has not been set.
            At :1417 char:18
            + writeHtmlHeader “$EnvironmentNameOut Farm Report” $resultsHTM
            + ~~~~~~~~~~~~~~~~~~~
            + CategoryInfo : InvalidOperation: (EnvironmentNameOut:String) [], RuntimeException
            + FullyQualifiedErrorId : VariableIsUndefined

            The variable ‘$CatalogHeaderName’ cannot be retrieved because it has not been set.
            At :1426 char:30
            + writeTableHeader $resultsHTM $CatalogHeaderName $CatalogHeaderNames $CatalogWidt …
            + ~~~~~~~~~~~~~~~~~~
            + CategoryInfo : InvalidOperation: (CatalogHeaderName:String) [], RuntimeException
            + FullyQualifiedErrorId : VariableIsUndefined

            The variable ‘$CatalogHeaderNames’ cannot be retrieved because it has not been set.
            At :1427 char:60
            + $CatalogResults | %{ writeData $CatalogResults $resultsHTM $CatalogHeaderNames}
            + ~~~~~~~~~~~~~~~~~~~
            + CategoryInfo : InvalidOperation: (CatalogHeaderNames:String) [], RuntimeException
            The variable ‘$emailFrom’ cannot be retrieved because it has not been set.

            + $emailMessage.From = $emailFrom
            + ~~~~~~~~~~
            + CategoryInfo : InvalidOperation: (emailFrom:String) [], RuntimeException
            + FullyQualifiedErrorId : VariableIsUndefined

            The variable ‘$emailTo’ cannot be retrieved because it has not been set.
            1464 char:23
            + $emailMessage.To.Add( $emailTo )
            + ~~~~~~~~
            + CategoryInfo : InvalidOperation: (emailTo:String) [], RuntimeException
            + FullyQualifiedErrorId : VariableIsUndefined

            The variable ‘$emailSubject’ cannot be retrieved because it has not been set.
            At:1465 char:25
            + $emailMessage.Subject = $emailSubject
            + ~~~~~~~~~~~~~
            + CategoryInfo : InvalidOperation: (emailSubject:String) [], RuntimeException
            + FullyQualifiedErrorId : VariableIsUndefined

            The variable ‘$emailPrio’ cannot be retrieved because it has not been set.
            At :1469 char:27
            + $emailMessage.Priority = ($emailPrio)
            + ~~~~~~~~~~
            + CategoryInfo : InvalidOperation: (emailPrio:String) [], RuntimeException
            + FullyQualifiedErrorId : VariableIsUndefined

            The variable ‘$smtpUser’ cannot be retrieved because it has not been set.
            At :1475 char:31
            + If ((![string]::IsNullOrEmpty($smtpUser)) -and (![string]::IsNullOrEmpty($smtpPW …
            + ~~~~~~~~~
            + CategoryInfo : InvalidOperation: (smtpUser:String) [], RuntimeException
            + FullyQualifiedErrorId : VariableIsUndefined

            Exception calling “Send” with “1” argument(s): “A from address must be specified.”
            At :1486 char:1
            + $smtpClient.Send( $emailMessage )
            + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
            + FullyQualifiedErrorId : InvalidOperationException

          • there seems to be an issue to read the XML – is the name from ps1 file and xml equal?

          • Method invocation failed because [System.Double] does not contain a method named ‘Split’

          • Sounds more like e PowerShell issue, what version of PowerShell is in use?

  • Name : ConsoleHost
    Version : 4.0

    The variable ‘$ErrorVDI’ cannot be retrieved because it has not been set.
    At X:\HC.ps1:1301 char:14
    + $ErrorVDI = $ErrorVDI + 1
    + ~~~~~~~~~
    + CategoryInfo : InvalidOperation: (ErrorVDI:String) [], RuntimeException
    + FullyQualifiedErrorId : VariableIsUndefined

    Method invocation failed because [System.Double] does not contain a method named ‘Split’.
    At X:\HC.ps1:1411 char:1
    + $XDmajor, $XDminor = $controllerversion.Split(“.”)[0..1]
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound

    The variable ‘$EnvironmentName’ cannot be retrieved because it has not been set.
    At X:\HC.ps1:1413 char:24
    + $EnvironmentNameOut = “$EnvironmentName $XDVersion”
    + ~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (EnvironmentName:String) [], RuntimeException
    + FullyQualifiedErrorId : VariableIsUndefined

  • Hi Sacha, we changed our license server last month from Windows Server 2012 to 2016. Ever since that time the script is able to get the LicenseServer name but the LicenseName, Count, InUse, Available are listed as n/a. Do you know what this might be? Thanks so much!

    • not enough permission on the new Lic Server – had a similar issue some weeks ago.

      • What permissions are required? I’m having the same issue where the html it’s only returning the license server name and everything else is n/a:
        LicenseName LicenseServer Count InUse Available
        n/a SERVERNAME n/a n/a n/a
        The account running the script is a full studio admin for the site and it’s also an administrator on the standalone licensing server. I’ve tried running this command: get-wmiobject -namespace “ROOT\CitrixLicensing” -computer YOURSERVER -query “select * from Citrix_GT_License_Pool” but i’m receiving a namespace error: get-wmiobject : Invalid namespace “ROOT\CitrixLicensing”. Thanks!

      • I downloaded an older version, 1.3.7, and I was able to get the license information to show up properly. When I used the 1.3.8 script it was not populating the info besides the name.

  • In Citrix Studio under Configuration/Administrators I am in a group with the Full Administrator Role. Is this the permissions you are referring? I’m not sure as to what permissions I need to check? Thanks.

  • Hi Sacha,

    Great script!!
    Is it possible to add Pending update (ImageOutofDate) and Image (MasterImageVM) used to the member server catalog to the table?

  • Hi Sacha,
    I just wanted to post a thank you for the great work you have done with this script.
    I have showed it to a few places and got it up and running for them to have an emailed report 3 times a day on their farm.
    Keep up the awesome work.

  • Hi Sacha,

    Thank you for this script.
    I wanted to know if just had the first part of the script, the one that controls the “controllerServer” with the ping the state ….. I would need this for the moment with the possible sending the result by mail.
    Thank you


  • Hi Sacha

    Such a great script. I wanted to add one more check in the same.
    Get-Brokerhypervisorconnection | select state , name in the same report as I have to schedule another report. Can you integrate in the same or suggest what shall be done?

  • Hi Sacha,

    I have implemented the Script for our current environment and everything working fine except license server details. In my case I am using Enterprise license and the license server is currently located on another server. I am looking for modification to pull out the license server report if license server hosted on separate servers.

    Thanks you in Advanced.

    • no, just enable it on line 119, configure license mode on line 126 of the XML.
      (if you want to troubleshoot, try the command you see on line 836 starting with Get-wmiObject)

  • I know in an earlier comment you said that the script can’t work for multiple sites.. is that something you plan to incorporate down the road? I’m also having an issue with Catalog info showing up on the html report. If I look in the text file generated, all of the information is there but on the html it lists the headers but nothing underneath. Am I missing something? Great script!

    • Multiple site is not so easy to implement, don’t have time currently to work on that. With with version you have the problem with catalog info? Because I thought this is working fine.

      • I didn’t think it’d be an easy task, no worries, I plan to just run it as a scheduled task for each site. I have the latest version, I just downloaded it this weekend. I didn’t start to look at the script in depth yet but the info is definitely in the .txt file, it’s just not showing up in the HTML.

      • I’ve tried 1.3.6, 1.3.7 and 1.3.8 to no avail. Apparently 1.3.3 did the trick for the MCs. I’ll just compare and figure out what the difference is and edit my copy of 1.3.8. I posted up higher too but I couldn’t get 1.3.8 to work for my licensing information, running the 1.3.7 script resolved that issue as well. Thanks

  • Hi Sacha, this script is really nice and I have it reporting in 3 regions simultaneously (Americas, Asia, Europe)! The only thing that is not working at the moment is the emailing part. This feature used to work but suddenly stopped. I have the XML file filled out just like before when it worked and verified our SMTP server is set to allow a relay through it. When looking at the log though there is nothing in there that shows it attempting to send email. Is there something possibly wrong in my XML file? Both the “From” and “To” email addresses have been verified as valid. Thanks.

  • Hi Sacha, this is a great script which I’ve have been using it for a number of years, many thanks. We are currently looking at migrating to Citrix Cloud, will this work with cloud connectors?

    • Unfortunately it’s not yet cloud tested, I assume it will not work “out of the box”, but I hope I can adopt the script next year to make it Citrix cloud-working.

  • Hi Sacha, the script is now running great and I managed to fix the emailing issue….mostly….but for some reason everyday after the script runs I get 11 identical HTML emails instead of just one. I was hoping you know what this might be. Also in the XML file where you allow to exclude catalogs in the ExcludedCatalogs section, what do you use to delineate the catalogs. Currently I’m using a comma, e.g.



  • CatalogName/assigned to user/assigned toDG section doesn/t seem to populate.
    Seems to detect the catalog names in the other sections though. What could be the reason for that?
    There are no exclusions in the XML and everything else seems to be fine.

  • Hello Sacha,
    Your script is great and running fine. My question is that I have a really large environment and wanted to get your thoughts on the “ExcludedCatalogs” section of the XML file and an error I’m experiencing that is causing the script to run far longer than it should. First off, currently the scripts takes over 12 hours to run. My first of two issues that I think account for the long run time is that I’m getting roughly 100 Windows 10 VDIs that get an error that “WMI connection failed – check WMI for corruption”. This error is followed by 11 instances with error “Description = The RPC server is unavailable”. Each one of these 11 instances stalls the script for about one minute which means this one server takes ~11 minutes to scan. This times dozens and dozens of servers really stretches the run time. I’ve compared servers that do not get the errors with ones that do and they seem identical and are both in the same MC. I’ve also scoured the internet and applied many suggestions to stop the RPC errors but nothing so far has worked. I feel like the script would run in as little as 1 hour if I could get past these RPC errors.

    Another thing I have tried to lessen the run time is to enable the excluded catalogs feature in the XML file. If I’m not mistaken, the script validates if a server is in the “excluded folder – skipping” machine catalog, however, I find these servers still go through all of the checks and thus with the RPC errors are taking 10+ minutes to run. Is there not a way that upon checking if a server is part of an excluded machine catalog, it will then completely skip that server and move on? In this case I’m not looking for a less cluttered report but a lesser run time.

    I was hoping that you or maybe someone else that might have run across this RPC error may have found a fix. Also, if there is a way for the excluded catalog feature to not only detect that a server is to be skipped but to also ignore it completely would be great. Thank so much.

    P.S. I also get the problem ASHKS speaks of that “CatalogName/assigned to user/assigned toDG section doesn/t seem to populate.”

    • Well, I’ve fixed all the WMI, WinRM and RPC error issues. Our security team updated a firewall rule and allowed a McAfee EPO update that allows communication between our controller server and Citrix devices. There is only one thing left which involves the excluded machine catalogs. I’m finding the script identifies the a device as belonging to a MC that has been designated as excluded, e.g. “ in excluded folder – skipping”. Even though the script recognizes this it still goes through and checks the machine, catalog, delivery group, PowerState, State, MaintenanceMode, HostedOn, VDAVersion, Assigned to, Tags, LastConnect, etc. Why does it not just completely skip? Other than this, the script is running WAY faster!

  • Hi Sacha

    Thank you for the great script, working pretty well. I would like to enhance the script with below data at my environments. Could you please help me with the code or hints to prepare the code.

    1. Total Active Sessions at Site level – Somewhere in the html, but interested to see like Jason’s Script work – XenApp 6.5 report
    2. Total Disconnected Sessions at Site level – Somewhere in the html, but interested to see like Jason’s Script work – XenApp 6.5 report

    3. Is there any way to list active sessions and disconnected sessions per each Virtual App Server in the same HTML report.

    Thank you again.

    • Hello Raj, the script is provided as is and contains no support. If you have Feature requests feel free to open an Issue in GitHub. On GitHub you can also contribute on the code.

  • Hi Sacha

    Finally I am able to add below changes to the script, and it works great now. planning to do something more.

    1. Removed the FQDN for all Xenapp machine names
    2. Active Sessions and Disconnected Sessions per each server.
    3. Total Active Sessions and Total Disconnected Sessions at Site level

    Again, thanks for excellent script. Keep rocking always.

  • Get-Content : Cannot find path ‘C:\Script\XA and XD HealthCheck_Parameters.xml’ because it does not exist.

    No se como crear el XML que me pide me podrían dar alguna ayuda por favor.

    • Unfortunately, I don’t speak Spanish, I can answer in German, French, Italian, and English, I hope English is ok.
      You need to add the Parameters file, which has the Name

Leave a Reply to Sacha Cancel reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Language switcher