-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWudf.ps1
More file actions
32 lines (31 loc) · 1.48 KB
/
Copy pathWudf.ps1
File metadata and controls
32 lines (31 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Get-CimInstance -ClassName Win32_PnPEntity | Where-Object Service -eq "WUDFRd"
$response = Read-Host "Are you sure you want to disable the device ? (Y/N)"
if ($response -match '^[yY]') {
Write-Host "Disabling ..." -ForegroundColor Yellow
pnputil.exe /disable-device (Get-CimInstance -ClassName Win32_PnPEntity | Where-Object Service -eq "WUDFRd").InstanceId /force
Write-Host "Done." -ForegroundColor Green
} else {
Write-Host "Skipping ..." -ForegroundColor Cyan
}
Get-PnpDevice -Status "OK" | ForEach-Object {
$filters = Get-PnpDeviceProperty -InstanceId $_.InstanceId -KeyName 'DEVPKEY_Device_UpperFilters','DEVPKEY_Device_LowerFilters' -ErrorAction SilentlyContinue
if ($filters.Data -eq "WUDFRd") {
[PSCustomObject]@{
FriendlyName = $_.FriendlyName
InstanceId = $_.InstanceId
}
$response = Read-Host "Are you sure you want to disable the device ? (Y/N)"
if ($response -match '^[yY]') {
Write-Host "Disabling ..." -ForegroundColor Yellow
pnputil.exe /disable-device $_.InstanceId /force
Write-Host "Done." -ForegroundColor Green
} else {
Write-Host "Skipping ..." -ForegroundColor Cyan
}
}
}
taskkill /F /IM WUDFHost.exe
Start-Sleep -Seconds 2
Write-Host "Disabled Drivers:"
Get-PnpDevice | Where-Object { $_.ConfigManagerErrorCode -eq 22 }
Get-PnpDevice | Where-Object { $_.ConfigManagerErrorCode -eq 22 } | Enable-PnpDevice