Windows Builds Hang at "Install-Module PSWindowsUpdate"

I have a couple of scripts I’d love to test via Travis on Windows. They work great locally but when tried in Travis hang. The command itself is Install-Module PSWindowsUpdate and doesn’t work inside the script I wrote (Powershell) or when added to the .travis.yml file. Below are two examples:


language: c

os: windows

    - PowerShell -Command 'Set-ExecutionPolicy -ExecutionPolicy RemoteSigned'

    - PowerShell -Command 'Install-Module PSWindowsUpdate'

    - PowerShell -File src/setup-windows.ps1
    - PowerShell -File src/update-windows.ps1
    - PowerShell -File src/spring-clean.ps1

My Powershell Script:

# Update Windows
# NOTE: Must be run in PowerShell, not command line (win + x -> Windows Powershell (Admin))

echo "Updating Windows..."

Install-Module PSWindowsUpdate

echo "Windows updated!"

Would love to know how I can fix this from hanging at this line. There is no output and Travis eventually times out without telling me what went wrong.

Please link to a build.

When I run this command locally with a freshly-installed PowerShell 7, I get a prompt:

PS C:\Users\Sasha> Install-Module PSWindowsUpdate

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this
repository, change its InstallationPolicy value by running the Set-PSRepository
 cmdlet. Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help
(default is "N"):

I reckon the build gets it, too, and gets stuck on it.

Looking at help Set-PSRepository, you need to run Set-PSRepository "PSGallery" -InstallationPolicy Trusted before running Install-Module.

That worked great, thank you so much!