Fully Automate deployments of GoToMeeting Updates – Part 2

In Part 1 of this blog post we covered the main control runbooks. In this post I am going to cover the main PowerShell script that will check if there is an update available on the Citrix website and download the update if a new version is found.

we will be creating the runbook that I called “Check for Update” in runbook 2

 

image

Check for new Version and download

image

 

########################################################################################################

# Author:Rob Plank

# Date: 5/2/2013

# Purpose: Download the current Goto Meeting MSI 

#

# Note: Unless Citrix changes the web site don't change anything besides the first two variables

########################################################################################################

 

$DownlaodPath = "C:\_IT\gotomeet.zip"                                    #Download File Name and Path

$VersionFile = "C:\_IT\gotomeeting.txt"                                  #Version File used to check for new Versions 

 

# Don't Edit Below

$CurrentVersion = 0                                                      

$Version = 0

$Build = 0

$URI = "http://support.citrixonline.com/gotomeeting/all_files/GTM020012" #Goto Meeting MSI Download page

 

function UpdateVerFile ($VerNum,$BuildNum,$File)

{

    #Delete the file if it exist

    if(Test-path -path $File) {Remove-item $File}

    #add current data to the file

    Add-Content $File $VerNum

    Add-Content $File $buildNum

}

 

function GetDownloadURL ($uri)

{

    $count = 0

    $downloaduri = ""

    #Open URL

    $hsg = Invoke-WebRequest -Uri $uri

    #Get Links with "Gotometting v"

    $MSILinks = $hsg.Links | Where {$_.innerhtml -like 'GoToMeeting v*'}

    Foreach ($Link in $MSILinks)

    {

        #Check for the first link

        if($count -eq '0')

        {

            $count ++

            #get the href from the link

            $NewURI = $Link.href

            #Open the URI

            $dlpage = Invoke-WebRequest $NewURI

            #Get the Download link

            $downloaduri = $dlpage.Links | Where {$_.outerText -eq 'click here'} | Select href

        }

    }

    #Return and add the prefex to the URL that is not in the link

    Return "http://support.citrixonline.com" + $downloaduri.href

}

 

function Downloadfile ($url,$path)

{

    #Download URL to the Path Provided

    $url = $url.replace('&','&')

    $client = new-object System.Net.WebClient

    $client.DownloadFile($url,$path)  

}

 

#open Web page

$hsg = Invoke-WebRequest -Uri $URI

#Get Links on the Page that have "GotoMeeting v"

$MSILinks = $hsg.Links | Where {$_.innerhtml -like 'GoToMeeting v*'}

Foreach ($Link in $MSILinks)

{

    #Check for the first link

    if($Version -eq '0')

    {

        #get internalHTML to String

        $interhtml = $Link.innerHTML.ToString()

        #Split the string for Version and Build numbers to store to variable

        $A = $interhtml.Split(',')

        $Version = $A[0].ToString().TrimStart('GoToMeeting v')

        $Build = $A[1].ToString().trimStart('build ')

    }

}

#Get Version from the last run if script has been run before

if((test-path -Path $VersionFile)) {$CurrentVersion = Get-Content $VersionFile}

#Check Version and Build numbers and if we should proceed with download

if(($Version -gt $CurrentVersion[0]) -or ($Build -gt $CurrentVersion[1])) 

{

    $downlaodurl = GetDownloadURL $URI

    Downloadfile $downlaodurl $DownlaodPath

    UpdateVerFile $Version $Build $VersionFile

    $Updated = $true

}

In the above powershell script I am downloading the current version of the GoToMeeting client and checking to see if the version number is newer than the last downloaded version, if it is newer we flip a bool variable to equal true. We return this variable and use it as a filter in the main control Runbook.

Return Data

image

Advertisements
This entry was posted in GoToMeeting, Powershell, SCO, SCORCH and tagged , , , . Bookmark the permalink.

One Response to Fully Automate deployments of GoToMeeting Updates – Part 2

  1. That’s good. So now gotomeeting gets automatically updated to a newer version if any, similar to RHUB web conferencing appliances.

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