Adds switch to force WMI usage over CIM

Implements #80
This commit is contained in:
Lord Hepipud 2020-07-27 11:47:22 +02:00
parent 5ba5261c8b
commit b2ee1d9315

View file

@ -2,7 +2,8 @@ function Get-IcingaWindowsInformation()
{
param (
[string]$ClassName,
$Filter
$Filter,
[switch]$ForceWMI = $FALSE
);
$Arguments = @{
@ -15,7 +16,7 @@ function Get-IcingaWindowsInformation()
);
}
if ((Get-Command 'Get-CimInstance' -ErrorAction SilentlyContinue)) {
if ($ForceWMI -eq $FALSE -And (Get-Command 'Get-CimInstance' -ErrorAction SilentlyContinue)) {
try {
return (Get-CimInstance @Arguments -ErrorAction Stop)
} catch {