no-wmi-cmdlets
What it does
Section titled “What it does”Reports a call of Get-WmiObject, Invoke-WmiMethod, Register-WmiEvent, Remove-WmiObject or Set-WmiInstance.
Why it matters
Section titled “Why it matters”The WMI cmdlets are not in PowerShell 7 and later. The CIM cmdlets (Get-CimInstance, Invoke-CimMethod) do the same work on Windows, use the newer remoting protocol, and are in both editions.
To fix, use the CIM cmdlet of the same job.
Example
Section titled “Example”...ConvertTo-SecureString $p... $p -AsPlainTextGet-WmiObject Win32_ProcessGet-CimInstance Win32_Process...Configuration
Section titled “Configuration”powershell: lint: rules: no-wmi-cmdlets: warn # off, warn (default), errorEnabled by the presets: powershell/psscriptanalyzer.
Suppress one line with sudsy-disable-next-line no-wmi-cmdlets in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| psscriptanalyzer | PSAvoidUsingWMICmdlet |
full |