bit.whisperer
bit.whisperer

Reputation: 1

How do I make a powershell script to set a HID device power saving option?

I am looking to create a powershell script to set the option for my HID device for "Allow the computer to turn off this device to save power". When I do it in device manager, the results are instant and the backlight on my keyboard can be set to always on and turning off after a few seconds at will.

I would like to control this with a script that can turn this option on and off.

However, the option "allow this device to wake the computer" is grayed out, but this is irrelevant.

I noticed that device manager is setting the DWord "SelectiveSuspendOn" whenever I set the setting. When I try to do it in the registry, the results are not instant. I am not sure what Device Manager is doing differently.

Is it possible someone can help me with this? The device instance path is USB\VID_1532&PID_028A&MI_01\6&7E5C38B&0&0001 and the class is HIDclass.

I have tried

$device = 'USB\\VID_1532&PID_028A&MI_01\\6&7e5c38b&0&0001_0';
    $PowerSaving = Get-CimInstance -ClassName MSPower_DeviceEnable -Namespace root\wmi | ? {$_.InstanceName -match $device}
    if ($PowerSaving.Enable){
        $PowerSaving.Enable = $true
        $PowerSaving | Set-CimInstance}

the script runs, but nothing happens.

Thanks again

Upvotes: 0

Views: 790

Answers (1)

bit.whisperer
bit.whisperer

Reputation: 1

I got it

Set-CimInstance -Namespace root\wmi -Query "SELECT * FROM MSPower_DeviceEnable WHERE InstanceName LIKE 'USB\\VID_1532&PID_028A&MI_01\\6&7e5c38b&0&0001_0'" -Property @{Enable=$False} -PassThru

Upvotes: 0

Related Questions