Another CimInstance

Started by spl, September 26, 2026, 04:53:00 AM

Previous topic - Next topic

spl

Haven't tried this with direct WB WMI code. Pretty interesting class, probably needs datetime and other formatting and better understanding of properties involved - but worked fine on my Win10 Surface Pro.
;Std_Out AntiMalWare
;Stan Littlefield 9/26/2026
;========================================================================================================================
Gosub udfs
args = $"Get-CimInstance -Namespace root\Microsoft\SecurityClient -ClassName AntimalwareHealthStatus | 
Select-Object ProductStatus,*end,*source,*version,*enabled | Tee-Object -variable t
$"

cmd="Powershell"                                                                                                       
msg='AntiMalWare Check'
BoxOpen(msg,cmd:" ":args:@LF:"PLEASE WAIT...MAY TAKE SOME TIME")
TimeDelay(2)
vals = Get_stdout()
BoxShut()
Message("AntiMalware Status Check",vals)
Exit
;======================================================================
:udfs
#DefineSubroutine Get_stdout()
ObjectClrOption("useany","System")
objInfo = ObjectClrNew("System.Diagnostics.ProcessStartInfo")
Output=""
timeOut = ObjectType("I2",5000)
objInfo.FileName = cmd
objInfo.RedirectStandardError = ObjectType("BOOL",@TRUE)
objInfo.RedirectStandardOutput = ObjectType("BOOL",@TRUE)
objInfo.UseShellExecute = ObjectType("BOOL",@FALSE)
objInfo.CreateNoWindow = ObjectType("BOOL",@TRUE)
objInfo.Arguments = args
oProcess = ObjectClrNew("System.Diagnostics.Process")
oProcess.StartInfo = objInfo
oProcess.Start()
oProcess.WaitForExit(timeout)
STDOUT = oProcess.StandardOutput.ReadToEnd()
STDERR = oProcess.StandardError.ReadToEnd()
Output = Output:STDOUT:@CRLF
If STDERR<>""
  Output = Output:"STDERR:":STDERR:@CRLF
Endif
oProcess = 0
objInfo = 0

Return (Output)
#EndSubroutine
Return
;==========================================================
Stan - formerly stanl [ex-Pundit]

JTaylor


spl

Thanks Jim. You could add 'name' to the list of select-object, and I did appreciate use of wildcard selection on properties.
Stan - formerly stanl [ex-Pundit]

SMF spam blocked by CleanTalk