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?
To enable disable a device, simply pipe the output of Get-PnpDevice to Disable-PnpDevice or Enable-PnpDevice. Please be sure your Get-PnpDevice command is targeting the correct device before piping to avoid accidentally disabling devices you'd rather keep enabled!
Open Start. Search for Device Manager and click the top result to open the app. Expand the branch with the driver you want to enable. Right-click the device and select the Enable device option.
Step 1: Open Windows Device Manager on your computer and expand the section of drivers you want to disable. Step 2: Right-click on the device driver and select “Disable device” from the context menu. Step 3: When there is a pop-up saying “Disabling this device will cause it to stop functioning.
Thankfully Powershell makes it easy to get, enable and disable devices in Device Manager using Get-PnpDevice, Enable-PnpDevice and Disable-PnpDevice To enable disable a device, simply pipe the output of Get-PnpDevice to Disable-PnpDevice or Enable-PnpDevice.
Yes I am trying to use powershell to disable any unneeded drivers in MDT out-of-box drivers befored they are deployed. I have found a script that pulls a list of superseded drivers, but it only list them. I was hoping to add to it to disable them so I do not have to manually do it to test.
Disables a PnP device. The Disable-PnpDevice cmdlet disables a Plug and Play (PnP) device. You must use an Administrator account to disable a device. This command disables a device that has the specified instance ID. Runs the cmdlet as a background job.
The simplest way to restart the graphics driver is mentioned in this Question: PowerShell disable and enable a driver But I cant use it because it needs admin privileges on executing. The Second and better approach is to use the win + ctrl + shift + b Hotkey which doesnt need admin rights.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With