Skip to content

Instantly share code, notes, and snippets.

View AhmedNSane's full-sized avatar

Ahmed Anssaien AhmedNSane

View GitHub Profile
@AhmedNSane
AhmedNSane / DisableUSBPowerManagement.ps1
Created May 26, 2025 01:55 — forked from ThioJoe/DisableUSBPowerManagement.ps1
PowerShell script to disable Windows power management on all currently connected serial ports, including most (if not all) USB devices and adapters.
# PowerShell script to disable Windows power management on all currently connected serial ports, including USB adapters
# In simpler terms, it prevents Windows from turning off connected serial devices to save power.
# Equivalent to right-clicking on a serial port device in Device Manager > Properties > "Power Management" Tab > Unchecking "Allow the computer to turn off this device to save power."
$hubs = Get-CimInstance -ClassName Win32_SerialPort | Select-Object Name, DeviceID, Description
$powerMgmt = Get-CimInstance -ClassName MSPower_DeviceEnable -Namespace root\wmi
foreach ($p in $powerMgmt) {
$IN = $p.InstanceName.ToUpper()
foreach ($h in $hubs) {