winutil
winutil copied to clipboard
Get-WmiObject in Powershell Core
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:
- Go to 'tweaks'
- Check on 'Disable Telemetry'
- Click on 'Run Tweaks'
- 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')
Still occurring with latest version. replacing Get-WMIObject
(deprecated) with Get-CimInstance
will fix the error on ps core.
Closed due to inactivity