When writing my SCOM Agent Update MP  I needed a way to get the SCOM Agent version from the file system.  There is one file that gets updated in every Update Rollup.  OMAgentTraceTMFVer.Dll that is located where in the \Tools\TMF directory where you installed the scom agent.  In my case C:\Program Files\Microsoft Monitoring Agent\Agent\Tools\TMF\OMAgentTraceTMFVer.Dll

I wrote this script to read the file version of this file to identify agent installed version.

Here is a similar VBscript that will pull that data. It works with SCOM 2012 R2 and SCOM 2016

Set objShell = WScript.CreateObject("WScript.Shell")
sngVersion = objShell.RegRead("HKLM\SOFTWARE\Microsoft\Microsoft Operations Manager.0\Setup\InstallDirectory")

Set objFSO = CreateObject("Scripting.FileSystemObject")
fileVer = objFSO.GetFileVersion(sngVersion & "Tools\TMF\" & "OMAgentTraceTMFVer.Dll")


select case fileVer
   case "7.1.10184.0"
      urVersion = "RTM"
      agentVersion = "2012 R2"
   case "7.1.10195.0"
      urVersion = "UR2"
      agentVersion = "2012 R2"
   case "7.1.10204.0"
      urVersion = "UR3"
      agentVersion = "2012 R2"
   case "7.1.10211.0"
      urVersion = "UR4"
      agentVersion = "2012 R2"
   case "7.1.10213.0"
      urVersion = "UR5"
      agentVersion = "2012 R2"
   case "7.1.10218.0"
      urVersion = "UR6"
      agentVersion = "2012 R2"
   case "7.1.10229.0"
      urVersion = "UR7"
      agentVersion = "2012 R2"
   case "7.1.10241.0"
      urVersion = "UR8"
      agentVersion = "2012 R2"
   case "7.1.10268.0"
      urVersion = "UR9"
      agentVersion = "2012 R2"
   case "7.1.10285.0"
      urVersion = "UR11"
      agentVersion = "2012 R2"
   case "8.0.10918.0"
      urVersion = "RTM"
      agentVersion = "2016"
   case "8.0.10931.0"
      urVersion = "UR1"
      agentVersion = "2016"   
case Else
      urVersion = "Unknown"
end select 

wscript.echo "Agent Version: " & agentVersion
wscript.echo "UR: " & urVersion

 

Here is the script in Powershell.   Modified from Kevin’s Agent Management Pack.  https://blogs.technet.microsoft.com/kevinholman/2017/05/09/agent-management-pack-making-a-scom-admins-life-a-little-easier/

function URVersion($Version)
{
  switch($Version)
  {
    # SCOM 2012
    "7.1.10184.0" {"2012 R2 RTM"} 
    "7.1.10195.0" {"2012 R2 UR2"} 
    "7.1.10204.0" {"2012 R2 UR3"} 
    "7.1.10211.0" {"2012 R2 UR4"} 
    "7.1.10213.0" {"2012 R2 UR5"} 
    "7.1.10218.0" {"2012 R2 UR6"} 
    "7.1.10229.0" {"2012 R2 UR7"} 
    "7.1.10241.0" {"2012 R2 UR8"} 
    "7.1.10268.0" {"2012 R2 UR9"} 
    "7.1.10285.0" {"2012 R2 UR11"} 
    "7.1.10292.0" {"2012 R2 UR12"} 
    "7.1.10302.0" {"2012 R2 UR13"} 
    "7.1.10305.0" {"2012 R2 UR14"} 				

    # SCOM 2016
    "8.0.10918.0" {"2016 RTM"} 
    "8.0.10931.0" {"2016 UR1"} 
    "8.0.10949.0" {"2016 UR2"} 
    "8.0.10970.0" {"2016 UR3"} 
    "8.0.10977.0" {"2016 UR4"} 				
  }
}
                        			
$SCOMRegKey = "HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager.0\Setup"
$SCOMPath = (Get-ItemProperty $SCOMRegKey).InstallDirectory
$SCOMPath = $SCOMPath.TrimEnd("\")

$AgentURFile = Get-Item $SCOMPath\Tools\TMF\OMAgentTraceTMFVer.Dll
$AgentURFileVersion = $AgentURFile.VersionInfo.FileVersion
$AgentURLevel = URVersion $AgentURFileVersion
$AgentURLevel

 

Categories:

Tags:

3 Responses

Leave a Reply

Your email address will not be published. Required fields are marked *