答案 0 :(得分:0)
以下脚本在Windows 10版本1809上为我运行:
$computer = '.' # $env:COMPUTERNAME
$namespaces = "ROOT\SecurityCenter", "ROOT\SecurityCenter2"
$classname = "FirewallProduct"
$ActiveFireWall = foreach ($namespace in $namespaces) {
$aux = Get-WmiObject -Class $classname -Namespace $namespace -ComputerName $computer
if ($aux) {
$aux | Select-Object -Property [a-z]* -ExcludeProperty PSComputerName,
Scope, Path, Options, ClassPath, Properties, SystemProperties,
Qualifiers, Site, Container
}
}
if ( $ActiveFireWall ) { $ActiveFireWall.displayName }