I've written a PowerShell Script to download, and autoupdate the MIB.cfg file from Solarwinds. It will also restart the services and web sites. It should work for any of the products that work with the MIB.cfg providing you have PowerShell 2.0 and the WebAdministration Module. I've only had a chance to test on Windows 2008 R2.
Please add comments...
################################################################################
# Get-SolarwindsMIB.cfg
#-------------------------------------------------------------------------------
# Download and install the most recent MIB.cfg from Solarwinds
# Script takes no parameters
# Performs the following funcitons:
# Downloads the MIB.ZIP file
# Extracts the MIB.cfg from the MIB.ZIP
# Checks the creation date/time of the current MIB.cfg
# Compares that with the date/time of the downloaded MIB.cfg
# If the downloaded is newer, rename the older one with a date-stamp
# and replace with the downloaded copy.
# Stop all Solarwinds Services
# Stop all websites
# Start all Solarwinds Services
# Start all websites
#-------------------------------------------------------------------------------
# Tested with:
# Orion NPM 10.X.X
# Windows 20008 R2 x64
################################################################################
# Location of the curernt MIB.cfg
$OrionNPMMIBLocation = "C:\ProgramData\SolarWinds\MIBs.cfg"
# MIB.zip download location
$MIBLink = `
"">solarwinds.s3.amazonaws.com/.../MIBs.zip"
# Temporary Location for working with the MIB
$MIBZip = "$env:temp\MIBS.zip"
# Create a the name for the MIB.cfg file
$MIBCfg = $MIBZip.Replace("zip", "cfg")
# Cleanup Temp Folder
Remove-Item "$env:temp\*" -Force -ErrorAction SilentlyContinue
# Create new Web Client
$WebClient = New-Object System.Net.WebClient
# Download from $MIBLink to $MIBZip
$WebClient.DownloadFile($MIBLink, $MIBZip)
# Create Shell Object
$Shell = New-Object -com Shell.Application
$Location = $Shell.Namespace( $env:temp )
# Extract Zip Contents
$ZipFolder = $Shell.Namespace( $MIBZip )
$Location.CopyHere( $ZipFolder.items() )
# Compare UTC Creation date on the newly downloaded and the original MIB.cfg
$DateNewFile = (Get-Item $MIBCfg ).CreationTimeUtc
$DateOldFile = (Get-Item $OrionNPMMIBLocation).CreationTimeUtc
# If the newly downloaded one was created after the current one...
if ( $DateNewFile -gt $DateOldFile )
{
Write-Host Replace MIB Configuration File
# Rename current MIB.cfg to MIB-YYYYMMDD.cfg for fail-back if necessary
Move-Item -Path $OrionNPMMIBLocation -Destination `
( $OrionNPMMIBLocation.Split(".")[0] + "-" + `
(Get-Date -format "yyyyMMdd") + "." + `
$OrionNPMMIBLocation.Split(".")[1] )
# Move the newly downloaded MIB.cfg to the proper location
Move-Item -Path $MIBCfg -Destination `
( (Get-Item ( $OrionNPMMIBLocation.Split(".")[0] + "-" + `
(Get-Date -format "yyyyMMdd") + "." + `
$OrionNPMMIBLocation.Split(".")[1] ) ).Directory.FullName )
# Stop all Solarwinds Services
Get-Service | `
Where-Object { $_.DisplayName -match 'Solarwinds*' } | `
Stop-Service
# Stop all Websites
Import-Module WebAdministration
Get-WebSite | Stop-Website
# Start all Solarwinds Services
Get-Service | `
Where-Object { $_.DisplayName -match 'Solarwinds*' } | `
Start-Service
# Start all Websites
Get-WebSite | Start-WebSite
}