-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix.ps1
More file actions
22 lines (17 loc) · 1016 Bytes
/
fix.ps1
File metadata and controls
22 lines (17 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# you can't disable/enable devices without having administrator privileges, so we need to ask for them
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
# stop the script if controllers can't be re-enabled
$ErrorActionPreference = "Stop"
foreach ($device in (Get-PnpDevice -FriendlyName 'HID-compliant game controller')) {
# sometimes when the bug happens, the controller shows as enabled even though it's disabled
# so just in case we disable it manually
try {
Disable-PnpDevice -InstanceId $device.InstanceId -Confirm:$false
}
# will throw an exception despite disabling the device properly so we just ignore it
catch {
}
# enable all controllers again
Enable-PnpDevice -InstanceId $device.InstanceId -Confirm:$false
}
Write-Output "Done."