Value does not fall within expected range for PSWindowsUpdate

Well!! I am trying to install windows update through PSWindows update and I ended up with an error called value does not fall within expected range

Helps to post the code you are working with. Make sure to use the ‘</>’ to format the code too.

Hi @neemobeer

Thanks for your response!!, Here is the piece of code which I am working and attached error message well

Install-PackageProvider -Name NuGet -MinimumVersion -Confirm:$False -Force

# Trust the PSGallery repository
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted

# Check if the PSWindowsUpdate module is installed
if (!(Get-Module -Name PSWindowsUpdate)) {
    # If the module is not installed, install it using the Install-Module cmdlet
    Install-Module PSWindowsUpdate -Confirm:$False -Force
	Import-Module -Name PSWindowsUpdate -Force

# Add the Microsoft Update service to the list of available update sources
# Add-WUServiceManager -ServiceID "7971f918-a847-4430-9279-4a52d1efe18d" -Confirm:$false
Add-WUServiceManager -MicrosoftUpdate -Confirm:$False

# Install all available updates & removed auto reboot
get-wuinstall -acceptall -microsoftupdate -recursecycle 10 -install
Install-WindowsUpdate -Install -AcceptAll -UpdateType Driver -MicrosoftUpdate -ForceDownload -ForceInstall -IgnoreReboot
# Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -AutoReboot | Out-File "C:\${env:COMPUTERNAME}_$(get-date -f yyyyMMdd)_MSUpdates.log"


I would throw a -Verbose on there and see what you get. Seems like you may have something going on outside of Powershell, maybe a WSUS server settings in place? Just guessing, the command works fine for me.

1 Like

Yeah it’s used work properly, After 50+ runs on same machine I ended up with this error.

But as you said I mentioned -verbose and tried I haven’t got any information, But now all commands are working after deleting Software Distribution Download data… Do you think is there any connection with this ?

I think it queries that data and it can become corrupt so maybe. Windows updates has always been a PITA.

I was searching for this issue from last 10 days, Thanks mate for your guidance and do you think any other settings will make these type of noise again

It could always crop up again. I used to have a script for blowing away the update cache and resetting everything and had to use it more than I care to admit.

Funny!!.. If possible can you please post the script here, It will help other as well…

That was year ago, but this looks like it does more or less the same thing Reset Windows Update Client Settings Script · GitHub

1 Like

Thanks for all you quick responses… :grinning: @neemobeer