Alert on Website Updates

When implementing a new Citrix environment I always want to try to keep up to date with the recommended Citrix and Windows Updates as proposed by Citrix. I know that on certain Citrix pages you can subscript to Hotfix alerts, but the main page I wanted to be alerted to was http://support.citrix.com/article/CTX129229 which contains all Citrix and Windows updates relating to Citrix XenApp 6.5.

So that this website could be checked regularly I created this PowerShell script which downloads the contents of the website and will trigger an email alert if some text is not present on the website. In my example script I am looking at the update on date, so if this date changes I will get an email. Once I have applied the appropriate update I would change Dec 31, 2013 to whatever the new update date is so that I will be alerted if it changes once again.

Please note, that this will actually work for any website if you just change the URL.

In a future revision of this I will make it smarter by automatically updating the updated on date. I assume I will be accomplish this by storing the current date in a text file which will update to the new date once an alert is triggered.

function WebCheck ($website, $check) {
$webClient = new-object System.Net.WebClient
$webClient.Headers.Add(“user-agent”, “PowerShell Script”)

$output = “”

$output = $webClient.DownloadString($website)
if ($output -like “*$check*”) {
write-host $website “Up to Date”
return $true
}
else {
write-host $website “Possible new updates available”
sendMail
return $false
}

}
#End Webcheck

function sendMail{

#SMTP server name
$smtpServer = “EMAIL SERVER

#Creating a Mail object
$msg = new-object Net.Mail.MailMessage

#Creating SMTP server object
$smtp = new-object Net.Mail.SmtpClient($smtpServer)

#Email structure
$msg.From = “EMAIL ADDRESS
$msg.ReplyTo = “EMAIL ADDRESS
$msg.To.Add(“EMAIL ADDRESS“)
$msg.subject = “Citrix 6.5 Hotfix Avaliable”
$msg.body = “Visit http://support.citrix.com/article/CTX129229”

#Sending email
$smtp.Send($msg)
}

$ctxupdcheck = WebCheck “http://support.citrix.com/article/CTX129229” “Dec 31, 2013”

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s