Script to install or update drivers directly from Microsoft Catalog

Windows10 does automatically install missing Drivers from the Microsoft Update Catalog after the OS Setup. All the Drivers are also available through Windows Update if you connect directly to Microsoft...But you will not get any Drivers if you are using ConfigMgr/WSUS as the driver category is not synced.

So what can you do if you are using WSUS but still want to get the Drives from Microsoft?

Note: the following examples are all PowerShell scripts... use at your own risk.

Register Microsoft Update as Source

The Windows Update Agent can handle multiple sources, the only thing you have to do is to add "Microsoft Update" as additional Update-Source. :

$UpdateSvc = New-Object -ComObject Microsoft.Update.ServiceManager            
$UpdateSvc.AddService2("7971f918-a847-4430-9279-4a52d1efe18d",7,"")            

To get an overview of all registerred sources run:
(New-Object -ComObject Microsoft.Update.ServiceManager).Services

Get all available Drivers

The following part does search and list all missing Drivers:

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

$Searcher.ServiceID = '7971f918-a847-4430-9279-4a52d1efe18d'
$Searcher.SearchScope =  1 # MachineOnly
$Searcher.ServerSelection = 3 # Third Party
          
$Criteria = "IsInstalled=0 and Type='Driver'"
Write-Host('Searching Driver-Updates...') -Fore Green     
$SearchResult = $Searcher.Search($Criteria)          
$Updates = $SearchResult.Updates
	
#Show available Drivers...
$Updates | select Title, DriverModel, DriverVerDate, Driverclass, DriverManufacturer | fl

Note: Windows Update does downgrade existing Drivers with the Version from the Microsoft Catalog !

Download Drivers

Let's download the Drivers from Microsoft... it may take a moment...

$UpdatesToDownload = New-Object -Com Microsoft.Update.UpdateColl
$updates | % { $UpdatesToDownload.Add($_) | out-null }
Write-Host('Downloading Drivers...')  -Fore Green
$UpdateSession = New-Object -Com Microsoft.Update.Session
$Downloader = $UpdateSession.CreateUpdateDownloader()
$Downloader.Updates = $UpdatesToDownload
$Downloader.Download()

Install Drivers

Check if the Drivers are all downloaded and trigger the Installation:

$UpdatesToInstall = New-Object -Com Microsoft.Update.UpdateColl
$updates | % { if($_.IsDownloaded) { $UpdatesToInstall.Add($_) | out-null } }

Write-Host('Installing Drivers...')  -Fore Green
$Installer = $UpdateSession.CreateUpdateInstaller()
$Installer.Updates = $UpdatesToInstall
$InstallationResult = $Installer.Install()
if($InstallationResult.RebootRequired) { 
Write-Host('Reboot required! please reboot now..') -Fore Red
} else { Write-Host('Done..') -Fore Green }

Cleanup

Some of my Environments did had the "Microsoft Update" source registerred by default and some not... If you want to remove the source to go back to the initial state, you can run:

$updateSvc.Services | ? { $_.IsDefaultAUService -eq $false -and $_.ServiceID -eq "7971f918-a847-4430-9279-4a52d1efe18d" } | % { $UpdateSvc.RemoveService($_.ServiceID) }

Note: The command verifies if the Update-Source is not the default source, otherwise you may not get updates anymore...