Monitoring Server login status

We have a 10 server XenApp 6.5 farm.  Often during the day we have to lock a server out (prohibit logins) for various reasons.  Our probelm is - we are forgetful and do not always rememeber to renable logins afterward.  Is there any way we can set up some type of email alert to show us all 10 server login statuses each morning?   Thinking probably not but thought I would inquire.
snyperjAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CoralonCommented:
Sure.. that's relatively easy with powershell.
1st upgrade to powershell v3 (minimum)
add-pssnapin -name Citrix* -erroraction silentlycontinue

$ServerStatus = get-xaserver | select-object -property ServerName,LogonsEnabled

$SMTPTo = 'name@domain.tld'
$SMTPFrom = 'DisabledServers@domain.tld'
$SMTPSubject = "Disabled Server List on $(get-date)"
$SMTPBody = "Current server status as of $(get-date)\r\n$ServerStatus"
$SMTPServer = 'mailserver@domain.tld'
$SMTPPort = 25

Send-MailMessage -To $SMTPTo -From $SMTPFrom -Subject $SMTPSubject -Body $SMTPBody -port $SMTPPort

Open in new window


Then just schedule the task to run every morning.

You could even add a line to re-enable the logons:
get-xaserver | where-object { $_.LogonsEnabled -eq 'Disabled' | $_.LogonsEnabled = 'Enabled' }

Open in new window


Coralon
snyperjAuthor Commented:
This sounds great, but I am not sure how to customize it for my info?

Can you help?

Lets say I have two three servers and their names are:
XenApp65-XA01, XenApp65-XA02, XenApp65-XA03

How do I enter them?

I tried:
$ServerStatus = get-XenApp65-XA01| select-object -property ServerName,LogonsEnabled

Open in new window


but that causes power shell to error with:
get-XenApp65-XA01 : The term 'get-XenApp65-XA01' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.

Also, we use Exchange for Mail, am I just entering the mail server name here:

$SMTPServer = 'mailserver@domain.tld'

Open in new window


Thanks
Dirk KotteSECommented:
with PS command "get-xaserver" you get a list of all XenApp Servers and their configuration.
(try it directly within PS)

but with the script i get the server-names but without Logon-state.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

snyperjAuthor Commented:
Not sure what I am doing wrongscreenshot
CoralonCommented:
You need to add the citrix snapin first

add-pssnapin -name citrix*

Coralon
snyperjAuthor Commented:
Almost there....  I can get the results of the servers in the powershell window, now I just need to get the email to send.  The script keeps telling me that no smtp server is entered, but I have entered the info for our exchange server, which is also what we have entered for the smtp values in our local scan-to-email devices, so I know it is correct.  WHat am I missing?
ee-upload.JPG
CoralonCommented:
Are you running PS 3.0 or PS 2.0?  If it is 2.0, then you have to use the old style .net methods.
http://stackoverflow.com/questions/23787576/how-to-send-powershell-2-0-email-across-any-version-of-windows-server

And of course, make sure your From address domain matches the internal domain your mail server is expecting. And of course, be careful about making sure your mail server address is correct for SMTP.

Coralon

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
snyperjAuthor Commented:
I am using 2.0
I modified the script as shown in screen 1.  I get the email now, but the body just says:
"Current server status as of 06/23/2015 18:03:34\r\n "  and that is is...

I cant get the server statuses to show in the body of the email?

If I run
get-xaserver | select-object -property ServerName,LogonsEnabled

Open in new window

in powershell, it DOES show them in the powershell window....

What do I need to modify to get them into the email body?

Thanks
powershell-2.jpg
snyperjAuthor Commented:
Thanks
CoralonCommented:
In your .net command all you do is set the smtp body switch to powershell command..

Taking the example from article..

$EmailFrom = "test@cscncoc.com"
$EmailTo = "bjackson@csncoc.com"
$Subject = "Test mail Subject"
$Body = Get-XAServer | select-object -property ServerName,LogonsEnabled | format-table
$SMTPServer = "AFSBS2K11"
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25)
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)

Coralon
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Citrix

From novice to tech pro — start learning today.