Skip to content

Instantly share code, notes, and snippets.

@pmsmith
Last active July 29, 2018 11:10
Show Gist options
  • Save pmsmith/7a4eaf87c5471f5dc4a547a29cc7fb1f to your computer and use it in GitHub Desktop.
Save pmsmith/7a4eaf87c5471f5dc4a547a29cc7fb1f to your computer and use it in GitHub Desktop.
DisableUSBPowerManagement
#- Disable 'Allow the computer to turn off this device to save power' for all USB hubs
#- This is the same as going into device manager and unselecting the option
#- Adapted from: https://social.technet.microsoft.com/Forums/azure/en-US/49991c73-9178-496d-a73e-d2f02a836844/usb-devices-and-usb-hub-power-management-disabling-under-device-properties?forum=winserverpowershell
$hubs = Get-WmiObject Win32_USBHub
$powerMgmt = Get-WmiObject MSPower_DeviceEnable -Namespace root\wmi
foreach ($p in $powerMgmt)
{
foreach ($h in $hubs)
{
if($($p.InstanceName.ToUpper()) -like "*$($h.PNPDeviceId)*" -and $p.Enable -ne $false)
{
Write-Host -ForegroundColor Green "Updating power management on $p"
$p.enable = $false
$p.psbase.put() | Out-Null
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment