windowspowershellhotfix

Detection script for windows hotfixes


So we have recently had issues with the KB971033 update within our network and i have managed to get a working script for removing it and reactivating windows, however when trying to get a detection script working to assure it only runs on effected computers i cant get it to correctly output true or false when testing against installed KBs.

So far this is what im running. No matter what i do it will output false. Anything obvious i am missing?

if ((get-hotfix).hotfixid -eq "KB971033") {$true} else {$false}

Solution

  • (get-hotfix).hotfixid returns an array, so you should not compare that with -eq.

    This ought to do it:

    ((Get-HotFix  | Select-Object -ExpandProperty HotFixID) -contains 'KB971033')
    

    or for short:

    (((Get-HotFix).HotFixID) -contains 'KB971033')