简体   繁体   中英

Powershell output for Microsoft Defender status

I'm very new to PowerShell and I have question in regards to Microsoft Intune and PowerShell.

I have this GetMPComputerStatus|select AMRunning to check if Defender is "Normal" or "Passive", that's the only two outcomes.

How do I make an if statement so I can get all the devices which returns "Passive"

Hope i'm asking the right question and I provided enough information to my problem

Best regards

When you say "get all the devices which returns "Passive"" , I assume you need to check different computers and filter out all that have their antimalware software not in "Normal" mode.

For that you can use the -CimSession parameter that allows you to enter (an array) of computernames to test.

$computers = 'PC01', 'PC02', 'PC03'                # the computers you need to check
Get-MpComputerStatus -CimSession $computers | 
Where-Object {$_.AMRunningMode -eq 'Passive' } |   # or use Where-Object {$_.AMRunningMode -ne 'Normal' }
Select-Object PsComputerName, AMRunningMode

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM