none
How to switch powerplan with instanceID RRS feed

  • Question

  • Hi,

    Regarding:

    https://devblogs.microsoft.com/scripting/use-powershell-and-wmi-or-cim-to-view-and-to-set-power-plans/

    $p = gwmi -NS root\cimv2\power -Class win32_PowerPlan -Filter "ElementName ='Power Saver'"

    Will only work with English versions of Windows.

    If I want an international script, I guess I must use instanceID.

    I tried the following, but it doesn't work. How should I filter the instanceID ?

    $powerplan = Get-WmiObject -Class Win32_PowerPlan -Namespace root\cimv2\power -Filter "instanceID=8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c”
    $powerPlan.Activate()

    $powerplan = Get-WmiObject -Class Win32_PowerPlan -Namespace root\cimv2\power -Filter "instanceID='8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c'”
    $powerPlan.Activate()
     
    $powerplan = Get-WmiObject -Class Win32_PowerPlan -Namespace root\cimv2\power -Filter "instanceID={8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c}”
    $powerPlan.Activate()

    $powerplan = Get-WmiObject -Class Win32_PowerPlan -Namespace root\cimv2\power -Filter "instanceID='{8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c}'”
    $powerPlan.Activate()

    • Moved by Bill_Stewart Wednesday, September 4, 2019 9:24 PM Abandoned
    Monday, April 22, 2019 8:16 AM

All replies

  • Get-WmiObject Win32_PowerPlan -namespace root\cimv2\power  |
         where{$_.instanceid -match '381b4222-f694-41f0-9685-ff5bb260df2e'}

    Or …

    Get-WmiObject Win32_powerplan -filter 'InstanceId LIKE "%381b4222-f694-41f0-9685-ff5bb260df2e%"' -namespace root\cimv2\power

    Or …

    get-wmiobject Win32_powerplan -filter 'InstanceId = "Microsoft:PowerPlan\\{381b4222-f694-41f0-9685-ff5bb260df2e}"' -namespace root\cimv2\power


    \_(ツ)_/



    • Edited by jrv Monday, April 22, 2019 8:56 AM
    Monday, April 22, 2019 8:51 AM