Ran across the need for this recently, and thought will share it out here. Do share your feedback, also I am working on making this better and see how I can extend it to other Lync and OCS roles.

Method 1: Using Power-shell

=======================

 PS C:\Users\Administrator> Get-WmiObject -query 'select * from win32_product' | where {$_.name -eq "Microsoft Office Communications Server 2007 R2, XMPP Gateway" -and $_.version -eq "3.5.6907.221"} | foreach {$_.name}

 (Entire power-shell command on a single line)

 This is assuming it is Windows 2008 Server x64 using Windows Power-shell 2.0 installed as per instructions here: http://msdn.microsoft.com/en-us/library/ff637750.aspx

 If this outputs: “Microsoft Office Communications Server 2007 R2, XMPP Gateway”, we are good, else we need to apply http://support.microsoft.com/kb/2404570, before any further analysis.

 

Method 2: Using Control Panel -> Programs and Features -> Installed Updates -> KB2404570  

=====================================================================