Inventory Windows Installations with Monitis and PowerShell
In the previous articles, we talked about how you can use WMI, PowerShell, and custom monitors to monitor a wealth of information with Monitis. Today, we’ll revisit the subject, and show how you can monitor windows skus and serial numbers with the same general technique.
Remember, to easily monitor anything with Monitis and PowerShell, you need to download our PowerShell module. We’ll start with a complete script, and break it up line by line:
Import-Module Monitis Connect-Monitis $monitorExists = Get-MonitisCustomMonitor -Name InstalledProducts if (-not $monitorExists) { Add-MonitisCustomMonitor -Name InstalledProducts -Parameter Product, SerialNumber, Version, ServicePack, ComputerName } $operatingSystem = Get-WmiObject win32_Product Update-MonitisCustomMonitor -Name WindowsInstallationInfo -value @{ Product = $operatingSystem.Caption Company = $operatingSystem.SerialNumber Version = $operatingSystem.Version ServicePack = $operatingSystem.ServicePackMajorVersion + "." + $operatingSystem.ServicePackMinorVersion ComputerName = $env:ComputerName }
The first 2 lines re import the monitis module and connect to monitis. Without parameters, connect-monitis will prompt for an ApiKey and a SecretKey, and the module will remember these for as long as you’re using Monitis.
Line 3 gets a monitor named WindowsInstalllationInfo and stores it in a variable named $monitorExists. If no monitor is found, Get-MonitisCustomMonitor returns nothing.
Line 4 checks if a monitor exists, and, if it didn’t, line 5 creates a new monitor called WindowsInstallationInfo with 4 parameters: Product, SerialNumber, Version, ServicePack, and ComputerName
Line 6 captures information from WMI about the operating system, which includes all of the information we need to know.
The rest of the script updates the WindowsInstallationInfo monitor in Monitis, with information pieced together from Win32_OperatingSystem.
Once you find any PowerShell script, it’s a piece of cake to take the script’s results and upload them to Monitis so you can graph them, track them, and view their values over time.
We’re still just getting starting showing you all of the things you can monitor with Monitis and PowerShell.
Monitor Everything with Monitis – And do it easily with PowerShell – Part 1
Monitor Everything with Monitis – And do it easily with PowerShell – Part 2
Monitor Everything with Monitis – And do it easily with PowerShell – Part 3
Monitor Everything with Monitis – And do it easily with PowerShell – Part 4
Monitor Everything with Monitis – And do it easily with PowerShell – Part 5
Monitor Everything with Monitis – And do it easily with PowerShell – Part 6
Monitor Everything with Monitis – And do it easily with PowerShell – Part 7
Monitor Everything with Monitis – And do it easily with PowerShell – Part 8
Monitor Everything with Monitis – And do it easily with PowerShell – Part 9