Udostępnij przez


UnikajuujusłówWMICmdlet

Poziom ważności: ostrzeżenie

Opis

Od programu PowerShell 3.0 polecenia cmdlet ciM powinny być używane za pośrednictwem poleceń cmdlet usługi WMI.

Nie należy używać następujących poleceń cmdlet:

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

Zamiast tego użyj następujących poleceń cmdlet:

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

Polecenia cmdlet ciM są zgodne ze standardami WS-Management (WSMan) i standardem Common Information Model (CIM), umożliwiając zarządzanie systemami operacyjnymi Windows i innych niż Windows.

Jak

Zmień na równoważne polecenie cmdlet oparte na modelu CIM.

  • Get-WmiObject ->Get-CimInstance
  • Remove-WmiObject ->Remove-CimInstance
  • Invoke-WmiMethod ->Invoke-CimMethod
  • Register-WmiEvent ->Register-CimIndicationEvent
  • Set-WmiInstance ->Set-CimInstance

Przykład

Nieodpowiednim

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

Odpowiedź prawidłowa

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