Last active
January 2, 2023 19:19
-
-
Save WinkelCode/cae44ddce205b5363c60f15b2748ad1e to your computer and use it in GitHub Desktop.
Use at your own risk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script to automatically remove "appleprecisiontrackpadbluetooth.inf" and "appleprecisiontrackpadusb.inf". | |
# Get installed drivers with pnputil and include previous line (the published name) | |
$drivers = (pnputil /enum-drivers | Select-String -Pattern "appleprecisiontrackpadbluetooth.inf|appleprecisiontrackpadusb.inf" -Context 1,0) | |
# Sanity check the results | |
switch ($drivers.Count) { | |
0 {Write-Host "No drivers found, exiting"; pause; exit} | |
1 {Write-Host "Only one driver found, are you sure you want to continue?"; Read-Host "Press any key to continue, or Ctrl+C to abort"; Write-Host "Continuing"} | |
2 {Write-Host "Two drivers found, continuing"} | |
default {Write-Host "More than two drivers found, something seems to be broken. Please check manually with 'pnputil /enum-drivers'"; pause; exit} | |
} | |
# For each found driver... | |
foreach ($driver in $drivers) { | |
# Get the "Published Name" for pnputil /delete-driver (doesn't work with "Original Name"). | |
$driverpubname = $driver.Context.PreContext -split " " | Select-Object -Last 1 | |
# The "original name" for info purposes. | |
$driverorigname = $driver.Line -split " " | Select-Object -Last 1 | |
Write-Host "Will remove $driverorigname ($driverpubname)" | |
Read-Host "Continue? (Note: If you aren't sure, check manually with 'pnputil /enum-drivers') - Press any key to continue, or Ctrl+C to abort" | |
# Without /force it won't work in most cases without other steps, shouldn't cause any issues here. | |
pnputil /delete-driver $driverpubname /force | |
} | |
Write-Host "Done" | |
pause | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment