远程检索 Windows Defender 状态

问题描述

我正在使用以下脚本远程检索 Windows Defender 状态。

$password = ConvertTo-securestring “myPassword” -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PSCredential (“myUserNamer”,$password)
$sessionoption = New-Cimsessionoption -Protocol WsMan
$session = New-Cimsession -ComputerName myMachineName -Credential $credentials -Sessionoption
Get-MpPreference -Cimsession $session

但是,我对 PowerShell 脚本和相关协议还很陌生。当我可能不得不在数百台计算机上运行这些信息时,这是检索这些信息的最佳方式吗?

解决方法

是否需要针对所有机器或选定机器?

例如: 你可以在你需要的机器上运行一个远程会话,然后运行命令。

Enter-PSSession [VMname]
Get-MpComputerStatus

将 [VMname] 替换为您要查找的 VM/计算机的名称。

Enter-PSSession Computer-01
Get-MpComputerStatus

如果这就是您要找的东西。