I am on SCOM 2019 UR2. I am using the PowerShell Monitoring – Community Management Pack.
I am part way through writing a separate monitor for checking free disk space for the DBA team on their SQL Servers.
I have written a rule that is scheduled to run every 5 minutes. This is a cut down version:
param([string]$Arguments)
$SplitArg = [string]$Arguments -split(",")
$Device = $SplitArg[0]
$Threshold = [int]$SplitArg[1]
$ServerName = hostname
$Details = ""
ForEach ($DiskDrive in Get-CimInstance -Class CIM_LogicalDisk | Select-Object * | Where-Object Name -EQ $Device){
$DiskDriveFreeGB = [math]::Round($DiskDrive.FreeSpace / 1024 / 1024 / 1024,2)
$PercentFree = ($DiskDrive.FreeSpace / $DiskDrive.Size) * 100
$PercentFreeDecimal = [math]::Round($PercentFree,2)
$Details = "The " + $DiskDrive.Name + " drive on " + $ServerName + " is at " + $PercentFreeDecimal + "%. Which is " + $DiskDriveFreeGB + "GB free.`r`n"
}
The parameter I pass within the rule is:
$Target/Property[Type=”MicrosoftWindowsLibrary7585010!Microsoft.Windows.LogicalDevice”]/Name$, 45
When the script runs, $Device will become C: and $Threshold becomes 45.
If I override that with something like this (where I change the end number):
$Target/Property[Type=”MicrosoftWindowsLibrary7585010!Microsoft.Windows.LogicalDevice”]/Name$, 65
Then the script stops working correctly. It no longer deciphers $Target/Property[Type=”MicrosoftWindowsLibrary7585010!Microsoft.Windows.LogicalDevice”]/Name$ as C:
$Device will become $Target/Property[Type=”MicrosoftWindowsLibrary7585010!Microsoft.Windows.LogicalDevice”]/Name$
but $Threshold becomes 65
Any thoughts please on why this might be? Thank you.