PSCertificateEnrollment icon indicating copy to clipboard operation
PSCertificateEnrollment copied to clipboard

Get-WmiObject and PowerShell 7

Open Viajaz opened this issue 3 years ago • 2 comments
trafficstars

Get-WmiObject is not supported in PowerShell 7, the existence of the Cmdlet should be checked before it is used and, if not found, Get-CimInstance should be used instead (or the other way around).

Example:

if(Get-Command 'Get-CimInstance' -ErrorAction SilentlyContinue) {
   # Use Get-CimInstance
} else {
   # Use Get-WmiObject
}

Viajaz avatar Feb 14 '22 04:02 Viajaz

Thanks very much for your contribution. I have not yet tested the module on PS higher than 5.x. I will make sure it'll work correctly with the next release. May I ask how your experience is so far with the module?

Sleepw4lker avatar Feb 14 '22 16:02 Sleepw4lker

It was exactly what I was looking for but I'm only using a few Cmdlets. I had started to write almost the exact same Cmdlets myself before finding yours.

Viajaz avatar Feb 14 '22 23:02 Viajaz