AvoidUsingWMICmdlet

Nivel de gravedad: Advertencia

Descripción

Esta regla detecta el uso de los cmdlets de Instrumentación de Gestión de Windows (WMI). Desde PowerShell 3.0, deberías usar cmdlets del Common Information Model (CIM) en lugar de los cmdlets WMI. Los cmdlets CIM cumplen con los estándares WS-Management (WSMan) y el estándar CIM, que permite la gestión de sistemas operativos Windows y no Windows.

No uses estos cmdlets de WMI:

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

Utiliza estos cmdlets CIM en su lugar:

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

Example

No conforme

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

Compliant

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