While on the phone with Microsoft I needed a way to check the version of the mommodules.dll on alot of systems to see if the patch was applying.
So, I tweaked a script I found long ago and then made it work in Powershell V1 (with help from #powershell user JasonMArcher). I would give credit to the original author, but I don’t remember who it was. (aka, if you are reading this, please let me know so I can give proper credit.)
$erroractionpreference = "Continue"
$a = New-Object -comobject Excel.Application
$a.visible = $True
$b = $a.Workbooks.Add()
$c = $b.Worksheets.Item(1)
$c.Cells.Item(1,1) = "Machine Name"
$c.Cells.Item(1,2) = "File Name"
$c.Cells.Item(1,3) = "Version"
$c.Cells.Item(1,4) = "Report Time Stamp"
$d = $c.UsedRange
$d.Interior.ColorIndex = 19
$d.Font.ColorIndex = 11
$d.Font.Bold = $True
$intRow = 2
$colComputers = get-content E:\SCOMScripts\patching\Servers.txt
foreach ($strComputer in $colComputers)
{
$c.Cells.Item($intRow,1) = $strComputer
Function GetFileInfo
{
$Path = "\\"+ $strComputer + "\C$\Program Files\System Center Operations Manager 2007\MOMModules.dll"
$File = get-item $Path
$c.Cells.Item($intRow,2) = $File.Name
$c.Cells.Item($intRow,3) = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($Path).ProductVersion
}
GetFileInfo
$c.Cells.Item($intRow,4) = Get-date
$intRow = $intRow + 1
}
$d.EntireColumn.AutoFit()
I did some modifications and here is another version that get’s the machine names from SCOM. This has to be ran from the Operations Manager Console.
$erroractionpreference = "Continue"
$a = New-Object -comobject Excel.Application
$a.visible = $True
$b = $a.Workbooks.Add()
$c = $b.Worksheets.Item(1)
$c.Cells.Item(1,1) = "Machine Name"
$c.Cells.Item(1,2) = "File Name"
$c.Cells.Item(1,3) = "Version"
$c.Cells.Item(1,4) = "Report Time Stamp"
$c.Cells.Item(1,5) = "Reporting Node"
$d = $c.UsedRange
$d.Interior.ColorIndex = 19
$d.Font.ColorIndex = 11
$d.Font.Bold = $True
$intRow = 2
$colComputers = get-agent
foreach ($strComputer in $colComputers)
{
$c.Cells.Item($intRow,1) = $strComputer.ComputerName
Function GetFileInfo
{
$Path = "\\"+ $strComputer.ComputerName.ToString() + "\C$\Program Files\System Center Operations Manager 2007\MOMModules.dll"
$File = $Path
$c.Cells.Item($intRow,2) = $File
$c.Cells.Item($intRow,3) = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($Path).ProductVersion
}
GetFileInfo
$c.Cells.Item($intRow,4) = Get-date
$c.Cells.Item($intRow,5) = $strComputer.PrimaryManagementServerName
$intRow = $intRow + 1
}
$d.EntireColumn.AutoFit()
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.