Q:

get-hotfix not working on Powershell v1....need alternative

I have the below code that does various things and checks hotfix info. I tried on Windows Server 2008 SP2 servers and they do not have Powershell v2 installed. So, instead of going through my estate and fixing this for the moment (there are 3000+ 2008 SP2 servers) - I need to change my code.
I know Win32_quickfixengineering can do the same thing but not too sure what i should change in my code - any help please:
$computerdel = gc env:computername

$t = "C:\buildlog\$(gc env:computername).log"
#$e = Test-Path $t
rm $t -ErrorAction SilentlyContinue

#if ( $e -eq $true ) { rm $t }
#else { Write-Host "Shortcut does not exist." }

$Logfile = "C:\buildlog\$(gc env:computername).log"

Function LogWrite
{
   Param ([string]$logstring)

   Add-content $Logfile -value $logstring
}

LogWrite -----------------------------------------------------------------------------------------------------------------------------------------------

$computer = gc env:computername
$Date = Get-Date
$ExecutionpolicySET = Set-ExecutionPolicy Unrestricted
$OSVersion = Get-WmiObject Win32_operatingsystem

LogWrite "Script has been run on $Date - This is Servers Local Time"
LogWrite $computer
LogWrite "Server type: "
LogWrite $OSVersion.name

$onetcp = ((get-childitem c:\windows\system32\drivers\tcpip.sys).Versioninfo.ProductMajorPart).tostring()
$twotcp = ((get-childitem c:\windows\system32\drivers\tcpip.sys).Versioninfo.ProductMinorPart).tostring() 
$threetcp = ((get-childitem c:\windows\system32\drivers\tcpip.sys).Versioninfo.ProductBuildPart).tostring() 
$fourtcp = ((get-childitem c:\windows\system32\drivers\tcpip.sys).Versioninfo.ProductPrivatePart).tostring() 

$onedfsr = ((get-childitem c:\windows\system32\dfsrs.exe).Versioninfo.ProductMajorPart).tostring() 
$twodfsr = ((get-childitem c:\windows\system32\dfsrs.exe).Versioninfo.ProductMinorPart).tostring() 
$threedfsr = ((get-childitem c:\windows\system32\dfsrs.exe).Versioninfo.ProductBuildPart).tostring() 
$fourdfsr = ((get-childitem c:\windows\system32\dfsrs.exe).Versioninfo.ProductPrivatePart).tostring()

$hotfix1 = Get-HotFix -Id KB2450944 -ErrorAction SilentlyContinue 
$hotfix2 = Get-HotFix -Id KB2582284 -ErrorAction SilentlyContinue
$hotfix3 = Get-HotFix -Id KB979808 -ErrorAction SilentlyContinue
$hotfix4 = Get-HotFix -Id KB2121690 -ErrorAction SilentlyContinue
$hotfix5 = Get-HotFix -Id KB973776 -ErrorAction SilentlyContinue
$hotfix6 = Get-HotFix -Id KB953325 -ErrorAction SilentlyContinue
$hotfix7 = Get-HotFix -Id KB977357 -ErrorAction SilentlyContinue
$hotfix8 = Get-HotFix -Id KB2505348 -ErrorAction SilentlyContinue
$hotfix9 = Get-HotFix -Id KB2285835 -ErrorAction SilentlyContinue
$hotfix10 = Get-HotFix -Id KB976655 -ErrorAction SilentlyContinue
$hotfix11 = Get-HotFix -Id KB979564 -ErrorAction SilentlyContinue
$hotfix12 = Get-HotFix -Id KB962969 -ErrorAction SilentlyContinue

LogWrite

    If ($hotfix1) {
        LogWrite "Hotfix KB2450944 is installed - This is DFSRS.exe Upgrade Hotfix" -BackgroundColor Green -ForegroundColor Black
    }
    else {
        LogWrite "Hotfix KB2450944 is NOT installed - Please ensure you install this hotfix - This is DFSRS.exe Upgrade Hotfix" -ForegroundColor "red"
    }
    LogWrite "DFSRS.exe Version on $computer is: ""$onedfsr.$twodfsr.$threedfsr.$fourdfsr"" "

LogWrite

    If ($hotfix4) {
        LogWrite "Hotfix KB2121690 is installed - This is 20 CPU Patch" -BackgroundColor Green -ForegroundColor Black
    }
    else {
    LogWrite "Hotfix KB2121690 is NOT installed - This is 20 CPU Patch" -ForegroundColor "red"
}

LogWrite

If ($OSVersion.version -eq "6.0.6002") 
{
    If ($hotfix5) {
        LogWrite "Hotfix KB973776 is installed - This is Robocopy Upgrade Hotfix" -BackgroundColor Green -ForegroundColor Black
    }
    else {
        LogWrite "Hotfix KB973776 is NOT installed - This is Robocopy Upgrade Hotfix" -ForegroundColor "red"
    }

    If ($hotfix6) {
        LogWrite "Hotfix KB953325 is installed - Resolves Paged Pool Exhusion Issue" -BackgroundColor Green -ForegroundColor Black
    }
    else {
        LogWrite "Hotfix KB953325 is NOT installed - Resolves Paged Pool Exhusion Issue" -ForegroundColor "red"
    }
    If ($hotfix12) {
        LogWrite "Hotfix KB962969 is installed - Resolves Command Line error on DFSRadmin.exe" -BackgroundColor Green -ForegroundColor Black
    }
    else {
        LogWrite "Hotfix KB962969 is NOT installed - Resolves Command Line error on DFSRadmin.exe" -ForegroundColor "red"
    }

}

ElseIf ($OSVersion.version -eq "6.1.7600")
{

    If ($hotfix2) {
        LogWrite "Hotfix KB2582284 is installed - This is TCPIP.sys Upgrade Hotfix" -BackgroundColor Green -ForegroundColor Black
        }
    else {
        LogWrite "Hotfix KB2582284 is NOT installed - Please ensure you install this hotfix - This is DFSRS.exe Upgrade Hotfix" -ForegroundColor "red"
        }

    LogWrite "TCPIP.sys Version on $computer is: ""$onetcp.$twotcp.$threetcp.$fourtcp"" "

LogWrite

    If ($hotfix3) {
        LogWrite "Hotfix KB979808 is installed - This is Robocopy R2 Pre-Seeding Upgrade" -BackgroundColor Green -ForegroundColor Black
        }
    else {
        LogWrite "Hotfix KB979808 is NOT installed - This is Robocopy R2 Pre-Seeding Upgrade" -ForegroundColor "red"
    }
LogWrite
    If ($hotfix7) {
        LogWrite "Hotfix KB977357 is installed - Resolves Memory Leak on WMI" -BackgroundColor Green -ForegroundColor Black
    }
    else {
        LogWrite "Hotfix KB977357 is NOT installed - Resolves Memory Leak on WMI" -ForegroundColor "red"
    }
LogWrite
    If ($hotfix8) {
        LogWrite "Hotfix KB2505348 is installed - Resolves Performance issues on WMI" -BackgroundColor Green -ForegroundColor Black
    }
    else {
        LogWrite "Hotfix KB2505348 is NOT installed - Resolves Performance issues on WMI" -ForegroundColor "red"
    }
LogWrite
If ($hotfix10) {
        LogWrite "Hotfix KB976655 is installed - Update for dfsro.dll" -BackgroundColor Green -ForegroundColor Black
    }
    else {
        LogWrite "Hotfix KB976655 is NOT installed - Update for dfsro.dll" -ForegroundColor "red"
    }
LogWrite
If ($hotfix11) {
        LogWrite "Hotfix KB979564 is installed - Dfsrclus.dll update" -BackgroundColor Green -ForegroundColor Black
    }
    else {
        LogWrite "Hotfix KB979564 is NOT installed - Dfsrclus.dll update" -ForegroundColor "red"
    }

LogWrite -----------------------------------------------------------------------------------------------------------------------------------------------

A:

The Get-Hotfix cmdlet when invoked with the -Id parameter runs a wmi query for each id in that parameter with that id in the where clause of the wmi query.
The Get-Hotfix cmdlet will throw an error when no hotfixes that match your criteria can be found. To suppress the error message you can add -ErrorAction SilentlyContinue
When running a wmi query using Get-WmiObject -query no error is thrown if no objects can be found matching the criteria in the query.
This means that the following two statements are equivalent (the second one will also work on Powershell v1):
Get-HotFix -Id KB2450944 -ErrorAction SilentlyContinue
Get-WmiObject -Query "Select * from Win32_QuickFixEngineering where HotFixID= 'KB2450944'"

In your code you should replace this block of code:
$hotfix1 = Get-HotFix -Id KB2450944 -ErrorAction SilentlyContinue 
$hotfix2 = Get-HotFix -Id KB2582284 -ErrorAction SilentlyContinue
$hotfix3 = Get-HotFix -Id KB979808 -ErrorAction SilentlyContinue
$hotfix4 = Get-HotFix -Id KB2121690 -ErrorAction SilentlyContinue
$hotfix5 = Get-HotFix -Id KB973776 -ErrorAction SilentlyContinue
$hotfix6 = Get-HotFix -Id KB953325 -ErrorAction SilentlyContinue
$hotfix7 = Get-HotFix -Id KB977357 -ErrorAction SilentlyContinue
$hotfix8 = Get-HotFix -Id KB2505348 -ErrorAction SilentlyContinue
$hotfix9 = Get-HotFix -Id KB2285835 -ErrorAction SilentlyContinue
$hotfix10 = Get-HotFix -Id KB976655 -ErrorAction SilentlyContinue
$hotfix11 = Get-HotFix -Id KB979564 -ErrorAction SilentlyContinue
$hotfix12 = Get-HotFix -Id KB962969 -ErrorAction SilentlyContinue

with this block of code:
$hotfix1 = Get-WmiObject -Query "Select * from Win32_QuickFixEngineering where HotFixID= 'KB2450944'" 
$hotfix2 = Get-WmiObject -Query "Select * from Win32_QuickFixEngineering where HotFixID= 'KB2582284'"
$hotfix3 = Get-WmiObject -Query "Select * from Win32_QuickFixEngineering where HotFixID= 'KB979808'"
$hotfix4 = Get-WmiObject -Query "Select * from Win32_QuickFixEngineering where HotFixID= 'KB2121690'"
$hotfix5 = Get-WmiObject -Query "Select * from Win32_QuickFixEngineering where HotFixID= 'KB973776'"
$hotfix6 = Get-WmiObject -Query "Select * from Win32_QuickFixEngineering where HotFixID= 'KB953325'"
$hotfix7 = Get-WmiObject -Query "Select * from Win32_QuickFixEngineering where HotFixID= 'KB977357'"
$hotfix8 = Get-WmiObject -Query "Select * from Win32_QuickFixEngineering where HotFixID= 'KB2505348'"
$hotfix9 = Get-WmiObject -Query "Select * from Win32_QuickFixEngineering where HotFixID= 'KB2285835'"
$hotfix10 = Get-WmiObject -Query "Select * from Win32_QuickFixEngineering where HotFixID= 'KB976655'"
$hotfix11 = Get-WmiObject -Query "Select * from Win32_QuickFixEngineering where HotFixID= 'KB979564'"
$hotfix12 = Get-WmiObject -Query "Select * from Win32_QuickFixEngineering where HotFixID= 'KB962969'"

