Does it show updates if you manually check for update?
There are GPOs which can block update over internet, have you checked on those.
Regards
Aravinth
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am running below script to install/update only sound driver but it's not detecting driver update or missing driver , It's only giving no driver update available. Is there anything missing in the code that's stopping the script to work?
$UpdateSvc = New-Object -ComObject Microsoft.Update.ServiceManager
$UpdateSvc.AddService2("7971f918-a847-4430-9279-4a52d1efe18d",7,"")
> check if the Windows Update service is running
if ((Get-Service -Name wuauserv).Status -ne "Running") {
Set-Service -Name wuauserv -StartupType Automatic
Start-Service -Name wuauserv
}
> check if there are updates available
$UpdateSession = New-Object -Com Microsoft.Update.Session
$UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
Write-Host 'Searching Driver-Updates...' -ForegroundColor Green
$SearchResult = $UpdateSearcher.Search("IsInstalled=0 and Type='Driver' and IsHidden=0")
> collect the updates
$UpdateCollection = New-Object -Com Microsoft.Update.UpdateColl
$Updates = for ($i = 0; $i -lt $SearchResult.Updates.Count; $i++) {
$Update = $SearchResult.Updates.Item($i)
> we are only interested in Audio driver updates
>> if you need to add more manufacturers, change the first part in the 'if' to for instance
>> $Update.DriverManufacturer -match 'Realtek|Conexant|Intel'
if ( $Update.DriverManufacturer -match 'Realtek|Conexant|Intel' -and
($Update.Title -like 'audio' -or $Update.Description -like 'audio')) {
if (-not $Update.EulaAccepted) { $Update.AcceptEula() | Out-Null }
[void]$UpdateCollection.Add($Update)
> output a PsCustomObject for display purposes only
$Update | Select-Object Title, DriverModel, DriverVerDate, Driverclass, DriverManufacturer
}
}
>no updates found; exit the script
if ($null -eq $Updates -or $Updates.Count -eq 0) {
Write-Host 'No Driver-Updates available...' -ForegroundColor Cyan
}
else {
> Show available driver updates...
$Updates | Format-List
>>download the updates
Write-Host 'Downloading driver updates...' -ForegroundColor Green
$Downloader = $UpdateSession.CreateUpdateDownloader()
$Downloader.Updates = $UpdateCollection
$Downloader.Priority = 3 # high
[void]$Downloader.Download()
>>install the updates
Write-Host 'Installing Drivers...' -ForegroundColor Green
$Installer = $UpdateSession.CreateUpdateInstaller()
>>accept all Critical and Security bulletins.
$Installer.ForceQuiet = $true
$Installer.Updates = $UpdateCollection
$InstallationResult = $Installer.Install()
$ResultCode = $InstallationResult.ResultCode
>> test if the computer needs rebooting
if ($InstallationResult.RebootRequired) {
Write-Host 'Reboot required! please reboot now..' -ForegroundColor Red
}
else {
Write-Host 'Done..' -ForegroundColor Green
}
}
> Clean-up COM objects
$null = System.Runtime.Interopservices.Marshal::ReleaseComObject($UpdateSearcher)
$null = System.Runtime.Interopservices.Marshal::ReleaseComObject($UpdateCollection)
$null = System.Runtime.Interopservices.Marshal::ReleaseComObject($SearchResult)
if ($Downloader) { $null = System.Runtime.Interopservices.Marshal::ReleaseComObject($Downloader)}
if ($Installer) { $null = System.Runtime.Interopservices.Marshal::ReleaseComObject($Installer)}
Does it show updates if you manually check for update?
There are GPOs which can block update over internet, have you checked on those.
Regards
Aravinth