Windows Update: 5 drivers

The previous posts just looked at installing software updates.  We can also get driver updates through Windows updates. A simple modification to the get-updates function sets this up.

function get-drivers {
[CmdletBinding()]
param (
[switch]$hidden
)
PROCESS{

$session = New-Object -ComObject Microsoft.Update.Session
$searcher = $session.CreateUpdateSearcher()

# 0 = false & 1 = true
if ($hidden){
$result = $searcher.Search("IsInstalled=0 and Type='Driver' and ISHidden=1" )
}
else {
$result = $searcher.Search("IsInstalled=0 and Type='Driver' 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 driver updates

.DESCRIPTION
Interrogates Windows updates for available driver updates only.
Optional parameter to display hidden updates

.PARAMETER  hidden
A switch to display the hidden updates

.EXAMPLE
get-drivers

Displays non-hidden updates

.EXAMPLE
get-drivers -hidden

Displays hidden updates
#>

}

 

We just change the type to Driver

I haven’t modified the install function but it is similar.

 

THINGS TO NOTE:

  1. This only displays drivers available through Windows Update
  2. It won’t pick up new drivers from the manufacturers site
  3. I would strongly recommend not installing new drivers automatically

Leave a Reply