1

I'm attempting to find all hotfixes declared in the $unhotfix array, then uninstall each if found.

$unhotfix ="KB2966826","KB2966827","KB2966828"

Get-Hotfix | ? (HotFixId -match $unhotfix) | `
${wusa.exe /uninstall /kb:$_.HotfixId /norestart /log} | wait-process

Using the following works for comparing one value:

Get-Hotfix | ? (HotFixId -match "KB2966826") | select HotFixId

However, I am missing something about matching arrays

Get-Hotfix | ? (HotFixId -match $unhotfixid) | select HotFixId

Gives no results.

2 Answers 2

1

Get-Hotfix has an -Id parameter that accepts an array of hotfix names.

Get-Hotfix -Id $unhotfix
Sign up to request clarification or add additional context in comments.

Comments

1
Get-HotFix | 
    Where-Object {$unhotfix.Contains($_.HotFixId)}

What this does it tests for the array of hotfix listings, and if it finds the HotFixId in that array, it'll return the matching hotfixes.

1 Comment

The Contains() method is case-sensitive. I'd recommend using the -contains operator instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.