SCOM MP中的PowerShell脚本
该脚本可在MP中运行
#param ($file,$threshold) #此处可定义file 和 threshold 参数,该参数可以从脚本外部接收 $threshold = 10 $file = "C:\inetpub\mpps_test3.txt" $sys = gwmi win32_computersystem [int]$mem = $sys.TotalPhysicalMemory/1024/1024/1024 $api = New-Object -ComObject "MOM.ScriptAPI" $bag = $api.CreatePropertyBag() if ($mem -ge $threshold) { $bag.AddValue("State","OK") $bag.AddValue("Description",$mem) (get-date -uformat "%Y%m%d%H%M") + " okk " + $mem |out-file $file -append } else { $bag.AddValue("State","Error") $bag.AddValue("Description",$mem) (get-date -uformat "%Y%m%d%H%M") + " Errorr " + $mem |out-file $file -append } $bag