Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <# :: PNPUTIL frontend by AveYo
- @title Uninstall OEM Drivers
- @start "" powershell.exe -noprofile -c "Invoke-Expression ('& {' + [io.file]::ReadAllText(\"%~f0\") + '}')" & exit/b
- :: can also copy-paste directly into a powershell window #>
- reg query "HKEY_USERS\S-1-5-20" 2>&1 | out-null; $admin = ($LASTEXITCODE -eq 0)
- $title='To uninstall OEM drivers, right-click script and Run as Administrator!'
- if ($admin) {$title='WARNING! selected OEM drivers will be uninstalled, press ESC to cancel'}
- $skip = $true
- $header = $true
- $oem = New-Object System.Collections.ArrayList
- $drivers = (pnputil.exe /enum-drivers) -join "`v" -split "`v`v";
- foreach($item in $drivers){
- if ($skip) { $skip = $false; continue }
- $obj = New-Object -TypeName PSObject
- $props = $item -split "`v"
- foreach($p in $props){
- $entry = $p -split ":\s+",2
- if ($entry[0] -ne ''){ $obj | Add-Member -MemberType NoteProperty -Name ($entry[0]) -Value ($entry[1]) -Force}
- }
- if ($header){
- $dummy = New-Object PsObject # safeguard for the first entry being selected by default
- $obj.psobject.properties | foreach { $dummy | Add-Member -MemberType $_.MemberType -Name $_.Name -Value ' ' }
- $null = $oem.Add($dummy)
- $header = $false
- }
- $null = $oem.Add($obj)
- }
- $oem | Out-GridView -Title $title -PassThru | foreach{$i=$_.('Published Name');pnputil.exe /delete-driver $i /force;echo "$i`n"}
- timeout /t -1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement