UPDATE: Version 2 of this script has been released
I recently created a Powershell script to report on several key items in a XenApp 6.x farm and e-mail a health check report. I run this script as a scheduled task on a XenApp server on a daily 7:00 am trigger. It gives XenApp administrators some confidence that the farm is in a good operational state for the day.
The script checks the health of a XenApp 6.x farm and e-mails two reports. The full farm health report is attached to the e-mail and any errors encountered are in an html report embedded in the email body.
This script checks the following:
– Ping response
– Logon enabled
– Assigned Load Evaluator
– ICA port response (at this stage only ICA, not CGP is tested)
– WMI response (to check for WMI corruption)
– Server uptime (to ensure scheduled reboots are occurring)
– Server folder path and worker group memberships are report for informational purposes
Location
Deptive - Commercial Bay
11-19 Customs Street West St
Commercial Bay Tower, Level 17, Room 1715
Auckland 1010
We also have a virtual office in Wellington.
Contact Details
0800 000 141
Postal Address
PO Box 34797,
Birkenhead, Auckland 0746
44 Comments
Awesome Script, any chance of adding free diskspace % with a tolerance level also? thanks
Nice script, like it.
Checking the XML & IMA service would be worth adding?
I have managed adding the PrintSpooler service myself, so checking additional services should be quite simple
Great to hear you like the script. I was planning on adding checking of services, and I like the idea of a free disk space check too. I’ll add this to the “to do list” for version 2.
Hi Jason
Great script, really helped me out. Did you manage to add the service check ?
I would like to check the XTE Server Service
Thanks
Can you past the code for adding checking the printer? Appreciate it.
#Check Print Spooler is Running
$PrintSpooler=(get-service -computer $server | Where-Object {$_.name -eq “Spooler”} | Select Status)
if($PrintSpooler.status -eq “running”) {
$results.Spooler = “Success”
} else {
“PrintSpooler Not Running” | LogMe -display -error
$results.Spooler = “Error”
}
Then you just need to output the results to the html file as per the other results.
Version 2 of the script should be out in a couple of weeks and contains more checks including print spooler & IMA service checks
any updates to this script which includes the IMA service checks
I get: Property ‘spooler’ cannot be found on this object; make sure it exists and is
ettable.
When I try and run it, though if I run the command straight from powershell it is fine… :S
Have you added the relevant code to add it to the HTML? is it possible that is your issue?
see below:
writeData $_.ComputerName, $_.FolderPath, $_.WorkerGroups $_.Ping, $_.Logons, $_.LoadEvaluator, $_.ICAPort, $_.WMI, $_.WeeklyReboot, $_.Spooler $resultsHTM
This will need to be added to all instances of the WriteData….
Yeah I’ve added it there… I think it is the checking part of it that’s causing the problem, but not sure why as I can run the command individually and it works i.e
get-service -computer xenapp01 | Where-Object {$_.name -eq “Spooler”} | Select Status
Works…. I’m guessing it’s not liking the $server for some reason.
Where have you added the snippit I originally posted, it needs to go here:
Get-XAServer | % {
$Results = “” | Select-Object ComputerName, FolderPath, WorkerGroups, Ping, Logons, LoadEvaluator, ICAPort, WMI, WeeklyReboot, Spooler, Flash
$server = $_.ServerName
$server | LogMe -display -progress
$Results.ComputerName = $server
$Results.FolderPath = $_.FolderPath
$Results.WorkerGroups = Get-XAWorkerGroup -ServerName $server | % {$_.WorkerGroupName}
#Check Print Spooler is Running
$PrintSpooler=(get-service -computer $server | Where-Object {$_.name -eq “Spooler”} | Select Status)
if($PrintSpooler.status -eq “running”) {
$results.Spooler = “Success”
} else {
“PrintSpooler Not Running” | LogMe -display -error
$results.Spooler = “Error”
}
you will probably require amending the following line to match also:
$Results = “” | Select-Object ComputerName, FolderPath, WorkerGroups, Ping, Logons, LoadEvaluator, ICAPort, WMI, WeeklyReboot, Spooler
If you wish I can send you the full updated script.
Thanks
Nice, this works great! Can’t reive the email, that’s a pity.
I added the SMTP server, to-email and from-email. But nothing! 🙁
Guess I just failed :facepalm:.
It’s working now!
Excellent script thanks Jason …
Found 1 prob, when the XA server is offline (there is bug where XA6 will hang while shutting down, but still respond to ping), it displays below error but still reports success in the script
Get-Service : Cannot open Service Control Manager on computer ‘CTX03’. This operation might require other privileges.
At C:tempXenAppServerHealthCheck.ps1:217 char:27
+ $PrintSpooler=(get-service <<<< -computer $server | Where-Object {$_.name -eq "Spooler"} | Select Status)
+ CategoryInfo : NotSpecified: (:) [Get-Service], InvalidOperationException
+ FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.GetServiceCommand
Also how do you check the ICA port in the script, it report success as well in above situation although you cannot telnet to port 1494.
Thanks.
Did you released the next version?
> Sambasiva
Sambasiva, unfortunately I have been busy with other projects and have not fully tested the updated script. It is so close too!
shaun@au, the script essentially does a telnet to 1494 so I am surprised to hear that the script reports 1494 as available but telnet fails. If you get this situation again and have time to work with me then drop me a message.
Great Script! Any updates???
Been trying to make some modifications myself with not much success…keep getting errors….I am still new to PS scripting so am learning alot!
Thanks in advance!
Sonia
Hi Sonia,
Finalising the update of v2 of this script has been on my “to do” list for a loooong time! I’ll away on holiday for a while and will try to get something done when I get back.
Jason
I am new to PS Scripting as well, but would and have been trying to incorporate the Server Load into this script without much success as well. Is it possible to do this?
Hi Jason. Is there any news on the updated script? It would be a massive help for us PS novices to have this finalised. Also, could you add a test for Session Reliability (2598) too? Many, many thanks
Hi,
I posted the updated script yesterday:
http://techblog.deptive.co.nz/2013/03/xenapp-farm-health-check-v2.html
It doesn’t have a check for Session Reliability though.
Jason
Hi Jason,
thank you for posting and updating your scritp.
Here are few lines I modified on v1, that should work even with the latest release in order to add smtp authentication.
On top, add:
—
$emailsend = $false
$smtpAuthUser = “” # Populate with DOMAINusername to enable smtp auth; fill in the smtpAuthPw too
$smtpAuthPw = “”
—
Replase the send line with:
—
if ($emailsend) {
if ($smtpAuthUser -ne “”) {
$secpw = ConvertTo-SecureString $smtpAuthPw -AsPlainText -Force
$authcred = New-Object System.Management.Automation.PSCredential ($smtpAuthUser, $secpw)
Send-MailMessage @mailMessageParameters -BodyAsHtml -Credential $authcred
} else {
Send-MailMessage @mailMessageParameters -BodyAsHtml
}
}
Thanks for the code, it looks useful. I’ll add it to the new script next time I make some updates.
Hi,
Is there a download link to V 1, assuming it is for XenApp 5.
thanks
Hi Jason,
Is there any Script for XenApp5?
Thanks
Fantastic work! Have been about to script one on my own, as I found yours.
Still, some socket connections are reported as errors, even if telnet on 1494 is ok.
Thanks a lot!
Is there a similar script for XA 5.0 on Windows 2008
Trying to get the excluded folders variable to work…
# Servers in the excluded folders will not be included in the health check
$excludedFolders = @(“ExcludeServers/servername”)
Created a subfolder….is it just a text file with servername in it????
Hi,
Firstly, please ensure you are using V2 of this script:
http://techblog.deptive.co.nz/2013/03/xenapp-farm-health-check-v2.html
The excluded folders are the Server folders shown in the AppCenter. So if you have a Test folder under Servers in AppCenter that you want to exclude from the heath report use:
$excludedFolders = @(“Servers/Test”)
Hope this makes sense to you.
I need to generate the report where i can pull the user session per application.
This is a birlliant script but does anyone use this script on a remote machine that isn’t a Citrix server. I need to know how to do the remoting of commands and all its doing is sending me an email with the table structure but with nothing in it. Any help would be appreciated, Thanks.
Wholesale jerseys outlet, only $19 Blazers factory.
Hi,
Beautiful script however I have seen a bug where it will hang on reaching a server which is not responding/RPC failing, can you please incorporate a timeout value so it doesn’t hung forever.
I have seen the exact same problem as “Vik” – “Beautiful script however I have seen a bug where it will hang on reaching a server which is not responding/RPC failing, can you please incorporate a timeout value so it doesn’t hung forever. – See more at: http://deptive.co.nz/xenapp-farm-health-report/#sthash.HtrmPF7L.dpuf”
Do you have a module that handles this?
[…] http://deptive.co.nz/xenapp-farm-health-report/ […]
Jason, great script to build on, i’ve expanded on your script,
see here,
http://leitchronicle.wordpress.com/2013/06/26/check-services-ping-specific-port-for-a-group-of-servers-configurable-by-csv-and-scalable-and-all-with-powershell/
thanks
What is EKG_WIDE.JPG and where do I get it?
Awesome, great script.
how to add Print server in this script? This is not a xenapp server but a print server for the xenapp environment.
Hi Jason,
Wonderful script.
However there seems to be an issue when the services are being check. If the services are not installed, the script reports them as “Error”, but not as “N/A”
In the function CheckService(), the below code does not work.
if (!(Get-Service -Name $ServiceName -ComputerName $server -ErrorAction Stop) ) { “$ServiceName is not available…” | LogMe -display; $ServiceResult = “N/A” }
Hi I am unable to download the script. I request you to kindly mail me the script to my ID; kdevendiran83@yahoo.in.
Thanks in Advance
Please sent me the script. I am unable to download the script.
Please e-mail a copy of the script as it is not downloadable due to a DNS error.
Thanks.