Quantcast
Channel: THWACK: Popular Discussions - Script Lab
Viewing all articles
Browse latest Browse all 9937

Need a PowerShell Script to Monitor XenApp "LoginsEnabled"

$
0
0

A few weeks ago I made a post in the SAM forum about the need to monitor XenApp LoginsEnabled through PowerShell. See Citrix XenApp 6.5 - Need to monitor "LoginsEnabled". aLTeReGo suggested I try the script lab instead.


Basically, If I run this command locally on a Citrix XenApp server:


Get-WmiObject -namespace "root\citrix" -query 'select LoginsEnabled from MetaFrame_Server'


I get the following result:

 

PS C:\Users\chi127> Get-WmiObject -namespace "root\citrix" -query 'select LoginsEnabled from MetaFrame_Server'

 

 

 

__GENUS          : 2

__CLASS          : MetaFrame_Server

__SUPERCLASS     :

__DYNASTY        :

__RELPATH        :

__PROPERTY_COUNT : 1

__DERIVATION     : {}

__SERVER         :

__NAMESPACE      :

__PATH           :

LoginsEnabled    : True

 

 

 

PS C:\Users\chi127>

 

I need a PowerShell script that will look at the last line, where it says LoginsEnabled. The possible results are True or False. If the result is True, then I need the SAM component to be up/green and if it is False I need it to show up as down/red. I figured it would be easy to just say that True=1 and False=0. Then I would configure the SAM component to go "critical" if the value is not equal to 1.

 

I tried using the following script in the SAM script editor but it does not work.

 

$XA01 = "CXA01"

 

$result = Get-WmiObject -namespace "root\citrix" -ComputerName $XA01 -Credential ${CREDENTIAL} -query 'select LoginsEnabled from MetaFrame_Server'

 

if ($result -match "True")

{$answer = 1}

else

{$answer = 0}

 

Write-Host 'Message.Login_Status_CXA01: ' "Login Status -" $XA01

Write-Host 'Statistic.Login_Status_CXA01: ' $answer


It always returns a value of 0, even if I change the line from [if ($result -match "True")] to [if ($result -match "False")]. It does the same thing if I run this script locally on the XenApp server (with the -Credential part removed). Here is what it shows in the SAM script editor:

 

Message.Login_Status_CXA01:           Login Status - CXA01

Statistic.Login_Status_CXA01:            0



My PowerShell knowledge is very basic. What am I doing wrong?


Viewing all articles
Browse latest Browse all 9937

Trending Articles



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