Bobby Batts
asked on
Differentiation Between Multiple Windows Updates
I wrote a script that produces a report that will indicate the update status of each server on my domain. When I review the report produced, I see that there are multiple entries in the report for a single server. They are distinguished by the following descriptions:
Update or Security Update. I understand the difference between the two descriptions.
What I am trying to achieve is a method to extract the latest updates without getting all updates applied for the most recent patch release per server.
Does anyone have a script that meet the above requirements or suggestions on what modification(s) I should make to the attached script.
Update or Security Update. I understand the difference between the two descriptions.
What I am trying to achieve is a method to extract the latest updates without getting all updates applied for the most recent patch release per server.
Does anyone have a script that meet the above requirements or suggestions on what modification(s) I should make to the attached script.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
oBdA,
That modification worked! Thank you. One final question. The script is currently reading the input from the Updates.txt file to the machine name. How would I read another column in the text that held a string that represents a name. For example "John Doe" would be the person responsible for the machine.
Example file:
Column#1 Column#2
DCRADUIS John Doe
The string in Column#2 will be on the same row as Column#1
Would I add a variable $Respon and add or modify @{Name in some way?
Lipotech
That modification worked! Thank you. One final question. The script is currently reading the input from the Updates.txt file to the machine name. How would I read another column in the text that held a string that represents a name. For example "John Doe" would be the person responsible for the machine.
Example file:
Column#1 Column#2
DCRADUIS John Doe
The string in Column#2 will be on the same row as Column#1
Would I add a variable $Respon and add or modify @{Name in some way?
Lipotech
Prepare the text file as csv with a header line::
ComputerName,Responsible
DCRADUIS,John Doe
Then use this:$servers = Import-Csv -Path .\WinUpVer\Updates.csv
$servers | ForEach-Object {
$Server = $_
"Processing $($Server.ComputerName) ... " | Write-Host -NoNewline -ForegroundColor White
Try {
$QFEGroups = Get-WmiObject -Class "Win32_QuickFixEngineering" -ComputerName $Server.ComputerName -ErrorAction Stop |
Select-Object -Property `
"Description",
"HotfixID",
@{Name="InstalledOn"; Expression={([DateTime]($_.InstalledOn)).ToLocalTime()}} |
Group-Object -Property Description
$LastHotfix = ($QFEGroups | ? {$_.Name -eq "Hotfix"}).Group | Sort-Object -Property InstalledOn | Select-Object -Last 1
$LastUpdate = ($QFEGroups | ? {$_.Name -eq "Update"}).Group | Sort-Object -Property InstalledOn | Select-Object -Last 1
$LastSecurityUpdate = ($QFEGroups | ? {$_.Name -eq "Security Update"}).Group | Sort-Object -Property InstalledOn | Select-Object -Last 1
"" | Select-Object -Property `
@{Name="ComputerName"; Expression={$Server.ComputerName}},
@{Name="Responsible"; Expression={$Server.Responsible}},
@{Name="Hotfix"; Expression={$LastHotfix.HotfixID}},
@{Name="HF_InstalledOn"; Expression={$LastHotfix.InstalledOn}},
@{Name="Update"; Expression={$LastUpdate.HotfixID}},
@{Name="UP_InstalledOn"; Expression={$LastUpdate.InstalledOn}},
@{Name="Security Update"; Expression={$LastSecurityUpdate.HotfixID}},
@{Name="SU_InstalledOn"; Expression={$LastSecurityUpdate.InstalledOn}},
"Error"
"OK." | Write-Host -ForegroundColor Green
} Catch {
$_.Exception.Message | Select-Object -Property `
@{Name="ComputerName"; Expression={$Server.ComputerName}},
@{Name="Responsible"; Expression={$Server.Responsible}},
"Hotfix",
"HF_InstalledOn",
"Update",
"UP_InstalledOn",
"Security Update",
"SU_InstalledOn",
@{Name="Error"; Expression={$_}}
$_.Exception.Message | Write-Host -ForegroundColor Red
}
} | Export-Csv -NoTypeInformation -Path "C:\WinUpVer\WinUpdateVerify.csv"
ASKER
oBdA,,
It worked like a charm. Thank you.
Excellent support.
Lipotech
It worked like a charm. Thank you.
Excellent support.
Lipotech
ASKER
Excellent support. Bravo!!
ASKER
Name Update Security Update Installed Date
DBServer01 KB979687 KB2726236 7/26/2015
RADServer01 KB979997 KB2726555 7/26/2015
TXServer01 KB879767 KB2726535 7/26/2015
Is there a way to use -Class "Win32_QuickFixEngineering
Lipotech