I am writing a C# application that, among other things, gathers status information about Windows Defender. On Windows 10, using ManagementObjectSearcher(@"Root\SecurityCenter2", "SELECT * FROM AntiVirusProduct")
works fine to get some initial information (e.g., Windows Defender is installed, is enabled, and is up-to-date), but on Windows Server 2019, I take an invalid namespace exception on Root\SecurityCenter2
.
Using PowerShell and
Get-WMIObject -namespace "root" -class "__Namespace" | Select Name
I've browsed through the WMI namespaces on Windows Server 2019, but don't see anything that jumps out at me as an equivalent/newer version of the SecurityCenter2
namespace. If I just assume that Windows Defender is installed and enabled, I can successfully gather other required details in the Root\Microsoft\Windows\Defender
namespace just fine. But I'd prefer to be able to check the general status of Windows Defender beforehand, using the AntiVirusProduct
class.
Is there an alternative namespace to SecurityCenter2
that can be used for performing this initial WMI query on Windows Server 2019?