0

Is there anyway to disable a pnp device immediately instead of requiring a reboot?

I'm trying to write a powershell script to disable a pnp device that triggers when my PC is idle (using Task Scheduler).

I have a situation where I need to listen to a microphone on the PC, but this is preventing my PC from going to sleep. If I disable the microphone (or uncheck the "Listen to this device" option) it goes to sleep fine

I can confirm this as well using powercfg -requests. As soon as I disable the microphone , or uncheck "Listen to this device", it no longer shows up as something keeping my PC awake.

Here is my current script (I know I can simplify it but I might expand it to disable other devices in the future)

$devices = (Get-PnpDevice | Where-Object {$_.FriendlyName -like "*Microphone (High Definition Audio Device)*" -and $_.Status -eq "OK"})

Foreach ($device in $devices)
{
    $device | Disable-PnpDevice -Confirm:$false
}

Now, this works but requires a restart... I can't find any info about forcing a device to disable (or enable) immediately.

NAM
  • 1
  • 1

0 Answers0