Looking at the get-update function we created earlier I wanted to tidy it up a bit.
|
001
002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 |
function get-update {
[CmdletBinding()] param ( [switch]$hidden ) PROCESS{ $session = New-Object -ComObject Microsoft.Update.Session # 0 = false & 1 = true $result = $searcher.Search(“IsInstalled=0 and Type=’Software’ and ISHidden=1″ ) } else { $result = $searcher.Search(“IsInstalled=0 and Type=’Software’ and ISHidden=0″ ) } if ($result.Updates.Count -gt 0 ){$result.Updates | select Title, IsHidden, IsDownloaded, IsMandatory, IsUninstallable, RebootRequired, Description } else { Write-Host ” No updates available” } } #process<# .SYNOPSIS Discovers available updates .DESCRIPTION Interrogates Windows updates for available software updates only. Optional parameter to display hidden updates .PARAMETER hidden A switch to display the hidden updates .EXAMPLE get-update Displays non-hidden updates .EXAMPLE get-update -hidden Displays hidden updates #> } |
Primary changes are:
- to add a switch to the function to control the display of hidden updates
- count the available updates and display message if there aren’t any
- add more properties to the output- 7 properties defaults to a list so more readable as well
- add comment based help
This is nice.
But do you know a way to just get driver updates?
It would be cool to have a function do get all the available windows printer drivers from windows update.
You substitute Driver for Software in the Type.
I’ve posted a function that does this BUT it shows only those drivers available through Windows updates it won’t show drivers only available from the original manufacturer
Hi Richard, how would you get the status of the last update via COM on a list of machines i.e. via QAD-computer ?
Pingback: Windows Updates: remote machines | Richard Siddaway's Blog
Pingback: Windows Updates: remote machines - Richard Siddaway's Blog