Reputation: 181
Sometimes after restart/coldboot I got a problem with my touchscreen driver in Win8, so I've to restart it manually by now.
So I want to write a script that starts after login, which will disable the driver and enables it again.
I actually found out to find the driver and that I can get a object list of the drivers via:
Get-WmiObject Win32_PnPSignedDriver| select devicename, driverversion | where {$_.devicename -like "I2C*"}
But adding "| Disable-Device
" to the end of the line will not work.
Can anyone tell me how I have to write the command correctly and start the script like an batch file?
Upvotes: 18
Views: 35607
Reputation: 3342
at least with Windows 10 it is a lot easier:
$d = Get-PnpDevice| where {$_.friendlyname -like "I2Cwhatever*"}
$d | Disable-PnpDevice -Confirm:$false
$d | Enable-PnpDevice -Confirm:$false
Upvotes: 22
Reputation: 990
Assuming you are using the Device Management cmdlets, I'd suggest using the Get-Device
cmdlet provided in the same pack to pass along the pipeline.
After a quick look, I found that Disable-Device doesn't take either of DeviceName or DriverVersion from the pipeline - and won't recognise either as it's only identifying parameter (-TargetDevice
).
The technet page suggests this, to disable a device:
$deviceName = Read-Host -Prompt 'Please enter the Name of the Device to Disable'; Get-Device | Where-Object -Property Name -Like $deviceName | Disable-Device
You could simply use something like this, assuming your devicename is similar using the Get-Device cmdlet:
Get-Device | where {$_.name -like "I2C*"} | Disable-Device
Upvotes: 4