Skip to content

Commit 8ab913f

Browse files
authored
Merge pull request #2 from andreitira/win10E-fix
Added `ExcludeHardwareId` parameter for `Get-WindowsUpdate`
2 parents 216d0e8 + 4ad1be0 commit 8ab913f

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ if ($updates) {
1818
}
1919
}
2020
```
21-
# If you want to exclude KBIDs
21+
# If you want to exclude KBIDs and updates for specific hardware ID's
2222

2323
```powershell
2424
Import-Module WindowsUpdates
2525
26-
$updates = Get-WindowsUpdate -Verbose -ExcludeKBId @("KB2267602")
26+
$updates = Get-WindowsUpdate -Verbose -ExcludeKBId @("KB2267602") -ExcludeHardwareId @("{084f01fa-e634-4d77-83ee-074817c03581}")
2727
```
2828

2929
## Compatibility

WindowsUpdates/WindowsUpdates.psm1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ function Get-WindowsUpdate {
9393
[CmdletBinding()]
9494
Param(
9595
[Parameter(Mandatory=$false)]
96-
[array]$ExcludeKBId=@()
96+
[array]$ExcludeKBId=@(),
97+
[Parameter(Mandatory=$false)]
98+
[array]$ExcludeHardwareId=@()
9799
)
98100
PROCESS {
99101
$updateSearcher = Get-UpdateSearcher
@@ -108,13 +110,14 @@ function Get-WindowsUpdate {
108110
}
109111
$updates = $updateResult.Updates
110112
$filteredUpdates = New-Object -ComObject $UPDATE_COLL_COM_CLASS
111-
112113
for ($i=0; $i -lt $updates.Count; $i++) {
113114
$update = $updates.Item($i)
114115
$updateKBId = ($update.KBArticleIDs -join ", KB")
115116
if ($ExcludeKBId -contains ("KB" + $updateKBId)) {
116117
Write-Verbose ("Exclude update KB{0}" `
117118
-f @($updateKBId))
119+
} elseif ($ExcludeHardwareId -contains $update.DriverHardwareID) {
120+
Write-Verbose ("Exclude update: {0}" -f @($Title))
118121
} else {
119122
Add-WindowsUpdateToCollection $filteredUpdates $update
120123
}

0 commit comments

Comments
 (0)