AvoidUsingWMICmdlet

Schweregrad: Warnung

Description

Diese Regel erkennt die Verwendung von Windows Management Instrumentation (WMI)-Cmdlets. Seit PowerShell 3.0 solltest du Common Information Model (CIM)-Cmdlets anstelle von WMI-Cmdlets verwenden. CIM-Cmdlets entsprechen den WS-Management (WSMan) Standards und dem CIM-Standard, der die Verwaltung von Windows und nicht-Windows Betriebssystemen ermöglicht.

Verwenden Sie diese WMI-Kommandos nicht:

  • Get-WmiObject
  • Remove-WmiObject
  • Invoke-WmiMethod
  • Register-WmiEvent
  • Set-WmiInstance

Verwenden Sie stattdessen diese CIM-Cmdlets:

  • Get-CimInstance
  • Remove-CimInstance
  • Invoke-CimMethod
  • Register-CimIndicationEvent
  • Set-CimInstance

Example

Nicht konform

Get-WmiObject -Query 'Select * from Win32_Process where name LIKE "myprocess%"' | Remove-WmiObject
Invoke-WmiMethod -Class Win32_Process -Name 'Create' -ArgumentList @{ CommandLine = 'notepad.exe' }

Konform

Get-CimInstance -Query 'Select * from Win32_Process where name LIKE "myprocess%"' | Remove-CimInstance
Invoke-CimMethod -ClassName Win32_Process -MethodName 'Create' -Arguments @{ CommandLine = 'notepad.exe' }