Skip to content

Windows system update with PSWindowsUpdate does not work #837

@BoYanZh

Description

@BoYanZh

Erroneous Behavior

topgrade --cleanup --verbose --only system throws an error Start-Process : A positional parameter cannot be found that accepts argument 'PSWindowsUpdate'..

Expected Behavior

Steps to reproduce

On a Windows 11 machine with scoop installed,

scoop install sudo
scoop install topgrade
topgrade --cleanup --verbose --only system

Possible Cause (Optional)

#671 adds Start-Process but it does not work for me. I tried to revert that commit and it works.

Problem persists without calling from topgrade

  • Yes
  • No

Did you run topgrade through Remote Execution

  • Yes
  • No

If yes, does the issue still occur when you run topgrade directlly in your
remote host

  • Yes
  • No

Configuration file (Optional)

I tried both pre_sudo = true and pre_sudo = false, the current version does not work but the old version works.

Additional Details

  • Operation System/Version

Windows Version 23H2 OS Build 22631.3810

  • Installation

Build from repo

  • Topgrade version (topgrade -V)

Topgrade 14.0.1

Verbose Output (topgrade -v)

$ topgrade --cleanup --verbose --only system
DEBUG Configuration at C:\Users\boyanzh\AppData\Roaming\topgrade.toml
DEBUG Loaded configuration: ConfigFile { include: None, misc: Some(Misc { pre_sudo: Some(true), sudo_command: None, disable: Some([System]), ignore_failures: None, remote_topgrades: Some(["debian", "wsl"]), remote_topgrade_path: None, ssh_arguments: None, tmux_arguments: None, set_title: None, display_time: Some(true), assume_yes: Some(true), no_retry: Some(true), run_in_tmux: None, cleanup: Some(true), notify_each_step: None, skip_notify: None, bashit_branch: None, only: None, no_self_update: None, log_filters: None }), pre_commands: Some({}), post_commands: None, commands: Some({}), python: Some(Python { enable_pip_review: None, enable_pip_review_local: None, enable_pipupgrade: None, pipupgrade_arguments: None }), composer: Some(Composer { self_update: None }), brew: Some(Brew { greedy_cask: None, greedy_latest: None, autoremove: None, fetch_head: None }), linux: Some(Linux { yay_arguments: None, aura_aur_arguments: None, aura_pacman_arguments: None, arch_package_manager: None, show_arch_news: None, garuda_update_arguments: None, trizen_arguments: None, pikaur_arguments: None, pamac_arguments: None, dnf_arguments: None, nix_arguments: None, nix_env_arguments: None, apt_arguments: None, enable_tlmgr: None, redhat_distro_sync: None, suse_dup: None, rpm_ostree: None, emerge_sync_flags: None, emerge_update_flags: None, home_manager_arguments: None }), git: Some(Git { max_concurrency: None, arguments: None, repos: None, pull_predefined: None }), containers: None, windows: Some(Windows { accept_all_updates: None, self_rename: None, open_remotes_in_new_terminal: None, wsl_update_pre_release: None, wsl_update_use_web_download: None }), npm: Some(NPM { use_sudo: None }), yarn: None, vim: None, firmware: Some(Firmware { upgrade: None }), vagrant: None, flatpak: Some(Flatpak { use_sudo: None }), distrobox: Some(Distrobox { use_root: None, containers: None }) }
DEBUG Version: 14.0.1
DEBUG OS: x86_64-pc-windows-gnu
DEBUG Args { inner: ["C:\\Users\\boyanzh\\scoop\\apps\\topgrade\\current\\topgrade.exe", "--cleanup", "--verbose", "--only", "system"] }
DEBUG Binary path: Ok("C:\\Users\\boyanzh\\scoop\\apps\\topgrade\\current\\topgrade.exe")
DEBUG self-update Feature Enabled: false
DEBUG Configuration: Config { opt: CommandLineArgs { edit_config: false, show_config_reference: false, run_in_tmux: false, cleanup: true, dry_run: false, no_retry: false, disable: [], only: [System], custom_commands: [], env: [], verbose: true, keep_at_end: false, skip_notify: false, yes: None, disable_predefined_git_repos: false, config: None, remote_host_limit: None, show_skipped: false, log_filter: "warn", gen_completion: None, gen_manpage: false, no_self_update: false }, config_file: ConfigFile { include: None, misc: Some(Misc { pre_sudo: Some(true), sudo_command: None, disable: Some([System]), ignore_failures: None, remote_topgrades: Some(["debian", "wsl"]), remote_topgrade_path: None, ssh_arguments: None, tmux_arguments: None, set_title: None, display_time: Some(true), assume_yes: Some(true), no_retry: Some(true), run_in_tmux: None, cleanup: Some(true), notify_each_step: None, skip_notify: None, bashit_branch: None, only: None, no_self_update: None, log_filters: None }), pre_commands: Some({}), post_commands: None, commands: Some({}), python: Some(Python { enable_pip_review: None, enable_pip_review_local: None, enable_pipupgrade: None, pipupgrade_arguments: None }), composer: Some(Composer { self_update: None }), brew: Some(Brew { greedy_cask: None, greedy_latest: None, autoremove: None, fetch_head: None }), linux: Some(Linux { yay_arguments: None, aura_aur_arguments: None, aura_pacman_arguments: None, arch_package_manager: None, show_arch_news: None, garuda_update_arguments: None, trizen_arguments: None, pikaur_arguments: None, pamac_arguments: None, dnf_arguments: None, nix_arguments: None, nix_env_arguments: None, apt_arguments: None, enable_tlmgr: None, redhat_distro_sync: None, suse_dup: None, rpm_ostree: None, emerge_sync_flags: None, emerge_update_flags: None, home_manager_arguments: None }), git: Some(Git { max_concurrency: None, arguments: None, repos: None, pull_predefined: None }), containers: None, windows: Some(Windows { accept_all_updates: None, self_rename: None, open_remotes_in_new_terminal: None, wsl_update_pre_release: None, wsl_update_use_web_download: None }), npm: Some(NPM { use_sudo: None }), yarn: None, vim: None, firmware: Some(Firmware { upgrade: None }), vagrant: None, flatpak: Some(Flatpak { use_sudo: None }), distrobox: Some(Distrobox { use_root: None, containers: None }) }, allowed_steps: [System] }
DEBUG Detected "C:\\Program Files\\PowerShell\\7\\pwsh.exe" as "pwsh"
DEBUG Executing command `C:\Program Files\PowerShell\7\pwsh.exe -NoProfile -Command 'Split-Path $profile'`
DEBUG Path "C:\\Users\\boyanzh\\Documents\\PowerShell" exists
DEBUG Path "C:\\Users\\boyanzh\\AppData\\Roaming\\.emacs.d" doesn't exist
DEBUG Cannot find "doas"
DEBUG Detected "C:\\Users\\boyanzh\\scoop\\shims\\sudo.cmd" as "sudo"

── 06:41:39 - Sudo ─────────────────────────────────────────────────────────────
DEBUG Executing command C:\Users\boyanzh\scoop\shims\sudo.cmd -v
-v: The term '-v' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
DEBUG Executing command hostname
DEBUG Executing command hostname
DEBUG Step "Windows update"
DEBUG Detected "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe" as "powershell"

── 06:41:43 - Windows Update ───────────────────────────────────────────────────
DEBUG Executing command C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -Command 'Get-Module -ListAvailable PSWindowsUpdate'
DEBUG Executing command C:\Users\boyanzh\scoop\shims\sudo.cmd 'C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe' -NoProfile -Command 'Start-Process powershell -Verb runAs -ArgumentList '\''Import-Module PSWindowsUpdate; Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -Verbose'\'''
Start-Process : A positional parameter cannot be found that accepts argument 'PSWindowsUpdate'.
At line:1 char:1

  • Start-Process powershell -Verb runAs -ArgumentList Import-Module PSW ...
  •   + CategoryInfo          : InvalidArgument: (:) [Start-Process], ParameterBindingException
      + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.StartProcessCommand
    
    

The Win32 internal error "The handle is invalid." 0x6 occurred while getting the console mode. Contact Microsoft Customer Support Services.

DEBUG Command failed: Err(
0: Command failed: C:\Users\boyanzh\scoop\shims\sudo.cmd 'C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe' -NoProfile -Command 'Start-Process powershell -Verb runAs -ArgumentList '\''Import-Module PSWindowsUpdate; Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -Verbose'\'''
1: C:\Users\boyanzh\scoop\shims\sudo.cmd failed: exit code: 1

Location:
src/steps/powershell.rs:122)
DEBUG Step "Windows update" failed:
0: Command failed: C:\Users\boyanzh\scoop\shims\sudo.cmd 'C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe' -NoProfile -Command 'Start-Process powershell -Verb runAs -ArgumentList '\''Import-Module PSWindowsUpdate; Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -Verbose'\'''
1: C:\Users\boyanzh\scoop\shims\sudo.cmd failed: exit code: 1

Location:
src/steps/powershell.rs:122

── 06:41:53 - Summary ──────────────────────────────────────────────────────────
Windows update: FAILED
DEBUG Desktop notification: Topgrade finished with errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugSomething isn't workingP-WindowsWindows issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions