I'm not a powershell guy so that is why this is harder than it probably should be.
I am trying to use a Powershell script within APM's Powershell component monitor that will show if windows defenders real-time detection is enabled. I created a script that works, but it only gets the result set from the solar server. I need an automatic variable like -computername '{IP}'. As shown within the KB documentation. Create a Windows PowerShell monitor
Here is my working script that does not work dynamically. Please help. Thanks.
$Enabled = ((Get-WmiObject -Namespace "ROOT\Microsoft\windows\defender" -class MSFT_MpComputerStatus -Property RealTimeProtectionEnabled).RealTimeProtectionEnabled) -as [int32]
$Message = ((Get-WmiObject -Namespace "ROOT\Microsoft\windows\defender" -class MSFT_MpComputerStatus -Property RealTimeProtectionEnabled).RealTimeProtectionEnabled) -as [string]
Write-Host "Statistic: $($Enabled)"
Write-Host "Message: $($Message)"