Quantcast
Channel: THWACK: All Content - Server & Application Monitor
Viewing all articles
Browse latest Browse all 12281

Powershell Monitor Coding Help

$
0
0

I am trying to write some code that will report on the number of sessions in the XenApp 6.0 estate marked as 'Down'. This is the first PowerShell I have tried to put into Solarwinds and need direction.

 

Below is the data I can see at this time?

1.png

I have put together some code together below which reports back exactly what I require. I am looking to get the total down sessions in the estate and also the users names. Here is the code:

Add-PSSnapin Citrix*
$sessions = Get-XASession | where { $_.State -eq "Down" }
$colResults = $sessions.count
foreach($session in $sessions)
{
if ($colResults.Count -eq 0) {
Write-Host "Message: No Down Sessions found.";
Write-Host "Statistic: 0";
}

else
{
Write-Host “Message:" $session.AccountName;

}
}
Write-host “Statistic:” $colResults;
exit 1;

 

This outputs this:

Message: DOMAIN\bob

Message: DOMAIN\paul

Message: DOMAIN\ringo

Message: DOMAIN\george

Statistic: 4

 

When I then paste this isto the template caretor and click the 'Get Script Output' button I get no errors and get a result of not defined. I am running the script remotely against a XenApp 6.0 server which I have confirmed the PowerShell addins exist on.

 

Can someone point me in the right direction as this script will be used as a template for a load of other outputs we require?

 

Thanks


Viewing all articles
Browse latest Browse all 12281

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>