winutil icon indicating copy to clipboard operation
winutil copied to clipboard

Get-WmiObject in Powershell Core

Open kdpuvvadi opened this issue 2 years ago • 1 comments

Describe the bug Get-WmiObject is deprecated in powershell core and it should be replaced with Get-CimInstance in case user opened the utility/script from core.

To Reproduce Steps to reproduce the behavior:

  1. Go to 'tweaks'
  2. Check on 'Disable Telemetry'
  3. Click on 'Run Tweaks'
  4. See error
Line |
1117 |              if (($(Get-WMIObject -class Win32_ComputerSystem | Select …
     |                     ~~~~~~~~~~~~~
     | The term 'Get-WMIObject' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Expected behavior Disable Telemetry

Additional context

Powershell 5 (exisitng)

($(Get-WMIObject -class Win32_ComputerSystem | Select-Object username).username).IndexOf('Administrator')

Powershell core

($(Get-CimInstance  -ClassName Win32_ComputerSystem | Select-Object username).username).IndexOf('Administrator')

kdpuvvadi avatar Oct 31 '22 10:10 kdpuvvadi

Still occurring with latest version. replacing Get-WMIObject(deprecated) with Get-CimInstance will fix the error on ps core. image

kdpuvvadi avatar Nov 26 '22 05:11 kdpuvvadi

Closed due to inactivity

github-actions[bot] avatar Feb 20 '24 03:02 github-actions[bot]