Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install-WindowsUpdate requires execution policy set to RemoteSigned #1036

Open
1 of 2 tasks
HenkPoley opened this issue Feb 12, 2025 · 3 comments
Open
1 of 2 tasks

Install-WindowsUpdate requires execution policy set to RemoteSigned #1036

HenkPoley opened this issue Feb 12, 2025 · 3 comments
Labels
C-bug Something isn't working

Comments

@HenkPoley
Copy link

You might want to set Set-ExecutionPolicy RemoteSigned before running Install-WindowsUpdate (from PSWindowsUpdate).

So it can actually run.

Technically you're then even supposed to save the current execution policy (Get-ExecutionPolicy) and then restore it after.

Erroneous Behavior

── 06:40:56 - Windows Update ───────────────────────────────────────────────────
The installer will request to run as administrator, expect a prompt.
Windows update failed:
   0: Command failed: `C:\WINDOWS\system32\sudo.exe 'C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe' -NoProfile 'Install-WindowsUpdate -Verbose' -AcceptAll`
   1: `C:\WINDOWS\system32\sudo.exe` failed: exit code: 1

Location:                                                                                                                                                      src\steps\powershell.rs:120                                                                                                                              Retry? (y)es/(N)o/(s)hell/(q)uit  

Expected Behavior

Powershell execution policy is set-up so Install-WindowsUpdate can run.

Steps to reproduce

topgrade --only system on a Windows system.

Possible Cause (Optional)

Restrictive PowerShell execution policies.

Problem persists without calling from topgrade

If I set the execution policy to RemoteSigned, then no.

Did you run topgrade through Remote Execution

  • Yes
  • No

Configuration file (Optional)

It's a freshly installed topgrade.

Additional Details

  • Operation System/Version

Windows 11 24H2 26100.2894

But it's a general PowerShell issue.

  • Installation

winget install topgrade

  • Topgrade version (topgrade -V)

topgrade 16.0.2

Verbose Output (topgrade -v)


@HenkPoley HenkPoley added the C-bug Something isn't working label Feb 12, 2025
@HenkPoley
Copy link
Author

HenkPoley commented Feb 12, 2025

The full command line starts the (older) powershell.exe

C:\WINDOWS\system32\sudo.exe 'C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe' -NoProfile 'Install-WindowsUpdate -Verbose' -AcceptAll

It appears you can tell that powershell.exe to use an execution policy override (-ExecutionPolicy RemoteSigned, order is important, don't put it at the end.):

C:\WINDOWS\system32\sudo.exe 'C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe' -ExecutionPolicy RemoteSigned -NoProfile 'Install-WindowsUpdate -Verbose' -AcceptAll

@niStee
Copy link
Contributor

niStee commented Feb 15, 2025

@HenkPoley please run command topgrade --version are you sure you are on 16.02?

as for me:

as well as:

@niStee
Copy link
Contributor

niStee commented Feb 15, 2025

@HenkPoley please check if #1041 fixes it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants