Script example

The SolarWinds MIB Database is a custom template using the Microsoft PowerShell script monitor. The script in this template calculates the age difference for a new database running on the Orion server by pulling the database and comparing creation dates.

Recommended configurations:

  • Polling frequency at 24 hours (86400 seconds) or higher
  • Polling timeout set depending on your Internet Connection speed

    For reference, the MIB database file download is over 200 MB.

  • Execution mode: Local Host

    Running the Web Client code over remote PowerShell may cause issues.

The script code used in this PowerShell monitor include extensive comments to clearly define the steps taken. Overall, the script:

  • Sets a temporary location and names for the MIB database
  • Downloads and extracts data from the zip
  • Compares the creation date between the original and downloaded MIB database
  • Provides content back to SAM with a message and statistic data of the amount of days older than the original
  • Saves the .cfg file if you want to update it at a later time

The script used in the template is as follows:

$MibUrl = ""
$LocalMib = "$( $env:ProgramData )\SolarWinds\Mibs.cfg"
# Temporary Location for working with the MIB
$MIBZip  = "$env:temp\"
# Create a the name for the MIB.cfg file
$MIBCfg  = $MIBZip.Replace("zip", "cfg")
# Cleanup Temp Folder
Remove-Item -Path $MIBCfg -Force -ErrorAction SilentlyContinue
# Create new Web Client
$WebClient = New-Object System.Net.WebClient
# Download from $MibUrl to $MIBZip
$WebClient.DownloadFile($MibUrl, $MIBZip)
# Create Shell Object
$Shell = New-Object -com Shell.Application
$Location = $Shell.Namespace( $env:temp )
# Extract MIBs.cfg file from Zip File
$ZipFolder = $Shell.Namespace( $MIBZip )
$MibFile = $ZipFolder.Items() | Where-Object { $_.Name -eq "MIBs.cfg" }
$Location.CopyHere( $MibFile )
# Compare UTC Creation date on the newly downloaded and the original MIB.cfg
$DateNewFile = (Get-Item -Path $MIBCfg  ).CreationTimeUtc
$DateOldFile = (Get-Item -Path $LocalMib).CreationTimeUtc
$DaysOld = [int]( ( $DateNewFile - $DateOldFile ).TotalDays )
Write-Host "Message: MIB Database on $( $env:ComputerName ) is $( ( $DateNewFile - $DateOldFile ).TotalDays.ToString("0") ) days old"
Write-Host "Statistic: $( ( $DateNewFile - $DateOldFile ).TotalDays.ToString("0") )"
$ExitCode = 0
Remove-Item -Path $MIBZip -ErrorAction SilentlyContinue
#We Leave the MIBs.cfg file in the $temp folder in case you want to update it.
exit $exitcode

To import the template via the Orion Web Console:

  1. Click Settings > All Settings > SAM Settings, and click Manage Templates.
  2. Click the Shared Templates on THWACK tab.

    A page opens and populates with available templates from THWACK.

  3. Enter SolarWinds MIB Database in the search field.
  4. Select a template file and click Import.
  5. Enter your THWACK account credentials when prompted.

    If you need an account, click Create Account and follow the steps.

  6. Click View Imported Templates to display with the imported template.

Options to extend the code:

  • Add error trapping. For example, you could check and ignore or respond with an error for negative values.
  • Add proxy and credentials code if your server is behind a proxy:

    # Create a Web Proxy
    $WebProxy = New-Object System.Net.WebProxy
    $WebProxy.Address = "http://proxy.address.local:80"
    # Create Credentials for Proxy
    $ProxyCreds = New-Object -TypeName System.Net.NetworkCredential
    $ProxyCreds.UserName = "ProxyUsername"
    $ProxyCreds.Password = "ProxyPassword"
    # Assign the Creds to the Proxy
    $WebProxy.Credentials = $ProxyCreds
    # Assign the Proxy to the Client
    $WebClient.Proxy = $WebProxy
  • Add code to clear out the saved .cfg file if needed.


If the database does not fully update, use the Orion Permission Checker or check permissions.