Поделиться через


Script to see highest version of a component installed on a OCS/Lync server

I had been doing some re-installation of my lab and was not sure if I had remembered to install the latest CU on all the servers. I created the following script to give me the highest version of any OCS/Lync component installed on my servers. The highest version is an indication of which CU has been installed, but it doesn’t tell you all CU components have been installed on the server.

The script require Windows Remote Management configured on all the servers (winrm quickconfig) and also that the user running it has the necessary permissions. I’ve run it against OCS 2007 R2 and Lync 2010 CU1 servers. No guarantees and your mileage may vary Smile

$computers = "srv1",”srv2”,”srv3”
$sb = {Get-ChildItem 'hklm:\software\microsoft\real-time communications'| foreach-object {Get-ItemProperty $_.pspath}}
foreach ($computer in $computers)
{
$all = Invoke-Command -ComputerName $computer -ScriptBlock $sb

# major.minor.build.patch
$highest = "0.0.0.0"

    foreach ($i in $all)
{

# get individual components of version
$a = $i.Version.split(".")
$b = $highest.Split(".")
# calculate a total
$avalue = ([int]$a[0]*1000)+([int]$a[1]*100)+([int]$a[2]*10)+([int]$a[3])
$bvalue = ([int]$b[0]*1000)+([int]$b[1]*100)+([int]$b[2]*10)+([int]$b[3])

# Compare totals
if ($avalue -gt $bvalue)
{
# we have a new highest version. Save that
$highest = $i.Version
}

}
write-host "Highest version seen on" $computer "is" $highest
}

Comments

  • Anonymous
    June 26, 2012
    The comment has been removed