-
Notifications
You must be signed in to change notification settings - Fork 33
Description
[2025-08-28T15:02:28.157673+00:00] PowerShell 7 is already installed
[2025-08-28T15:02:28.164739+00:00] Installing powershell modules in scope: AllUsers
[2025-08-28T15:02:28.820481+00:00] NuGet provider is already installed
[2025-08-28T15:02:48.427537+00:00] Microsoft.Winget.Client is already installed
[2025-08-28T15:02:48.816015+00:00] Microsoft.WinGet.Configuration is already installed
[2025-08-28T15:02:48.816773+00:00] Updating WinGet
[2025-08-28T15:02:48.817468+00:00] Attempting to repair WinGet Package Manager
[2025-08-28T15:02:49.081398+00:00] �[33;1mVERBOSE: Already running on MTA�[0m
[2025-08-28T15:02:49.384832+00:00] �[33;1mVERBOSE: WinGet is in a good state.�[0m
[2025-08-28T15:02:49.462218+00:00] Done Reparing WinGet Package Manager
[2025-08-28T15:03:07.707101+00:00] Running in the provisioning context
[2025-08-28T15:03:07.712476+00:00] Running package install: winget install OpenJS.NodeJS
[2025-08-28T15:03:08.966775+00:00]
[2025-08-28T15:03:08.966815+00:00] '$(
[2025-08-28T15:03:08.966817+00:00] $processCreation = Invoke-CimMethod -ClassName Win32_Process -MethodName Create -Arguments @{CommandLine =
[2025-08-28T15:03:08.966878+00:00] "C:\Program Files\PowerShell\7\pwsh.exe $($mtaFlag) -Command "$($installPackageCommand)"" }
[2025-08-28T15:03:08.966898+00:00] if (!($processCreation) -or !($processCreation.ProcessId)) {
[2025-08-28T15:03:08.966998+00:00] Write-Error "Failed to install package. Process creation failed."
[2025-08-28T15:03:08.967067+00:00] exit 1
[2025-08-28T15:03:08.967153+00:00] }
[2025-08-28T15:03:08.967348+00:00] $process = Get-Process -Id $processCreation.ProcessId
[2025-08-28T15:03:08.967414+00:00] $handle = $process.Handle # cache process.Handle so ExitCode isn't null when we need it below
[2025-08-28T15:03:08.967417+00:00] $process.WaitForExit()
[2025-08-28T15:03:08.967439+00:00] $installExitCode = $process.ExitCode
[2025-08-28T15:03:08.967472+00:00] if ($installExitCode -ne 0) {
[2025-08-28T15:03:08.967541+00:00] if ($PsInstallScope -eq "CurrentUser") {
[2025-08-28T15:03:08.967611+00:00] # try executing the commandlet via Start-Process instead of using Invoke-CimMethod, as this works
[2025-08-28T15:03:08.967642+00:00] better in some cases
[2025-08-28T15:03:08.967699+00:00] $process = Start-Process -FilePath "C:\Program Files\PowerShell\7\pwsh.exe" -ArgumentList "-Command
[2025-08-28T15:03:08.967756+00:00] $($installPackageCommand)" -PassThru
[2025-08-28T15:03:08.967817+00:00] $handle = $process.Handle # cache process.Handle so ExitCode isn't null when we need it below
[2025-08-28T15:03:08.967876+00:00] $process.WaitForExit()
[2025-08-28T15:03:08.967922+00:00] $installExitCode = $process.ExitCode
[2025-08-28T15:03:08.967971+00:00] if ($installExitCode -ne 0) {
[2025-08-28T15:03:08.968031+00:00] Write-Error "Failed to install package. Exit code: $($installExitCode)."
[2025-08-28T15:03:08.968084+00:00] exit 2
[2025-08-28T15:03:08.968138+00:00] }
[2025-08-28T15:03:08.968188+00:00] }
[2025-08-28T15:03:08.968245+00:00] else {
[2025-08-28T15:03:08.968298+00:00] Write-Error "Failed to install package. Exit code: $($installExitCode)."
[2025-08-28T15:03:08.968348+00:00] exit 1
[2025-08-28T15:03:08.968414+00:00] }
[2025-08-28T15:03:08.968468+00:00] }
[2025-08-28T15:03:08.968569+00:00] # read the output file and write it to the console
[2025-08-28T15:03:08.968629+00:00] if (Test-Path -Path $tempOutFile) {
[2025-08-28T15:03:08.968710+00:00] $unitResults = Get-Content -Path $tempOutFile -Raw | Out-String
[2025-08-28T15:03:08.968729+00:00] Write-Host $unitResults
[2025-08-28T15:03:08.968799+00:00] Remove-Item -Path $tempOutFile -Force
[2025-08-28T15:03:08.968819+00:00] $unitResultsObject = $unitResults | ConvertFrom-Json
[2025-08-28T15:03:08.968918+00:00] # If installer failed with NoApplicableInstallers, write actionable error and exit
[2025-08-28T15:03:08.968999+00:00] if ($unitResultsObject.Status -eq "NoApplicableInstallers") {
[2025-08-28T15:03:08.969049+00:00] Write-Error "Installer failed with NoApplicableInstallers. This might mean that there are no machine
[2025-08-28T15:03:08.969133+00:00] wide installers, or only machine wide installers, for package $($Package) in Winget. Please try moving it from
[2025-08-28T15:03:08.969191+00:00] userTasks to tasks, or from tasks to userTasks."
[2025-08-28T15:03:08.969271+00:00] exit 1
[2025-08-28T15:03:08.969295+00:00] }
[2025-08-28T15:03:08.969397+00:00] # If installer failed with ERROR_INSTALL_ALREADY_RUNNING (1618), wait for 60 seconds and retry once
[2025-08-28T15:03:08.969438+00:00] if (($installerAlreadyRunningRetries -lt 1) -and
[2025-08-28T15:03:08.969539+00:00] (
[2025-08-28T15:03:08.969568+00:00] ($unitResultsObject.InstallerErrorCode -eq "1618") -or
[2025-08-28T15:03:08.969632+00:00] ($unitResultsObject.ExtendedErrorCode -like "Another installation is already in progress")
[2025-08-28T15:03:08.969703+00:00] )
[2025-08-28T15:03:08.969730+00:00] ) {
[2025-08-28T15:03:08.969800+00:00] Write-Host "Installer failed with ERROR_INSTALL_ALREADY_RUNNING (1618), waiting for 60 seconds and
[2025-08-28T15:03:08.969847+00:00] retrying"
[2025-08-28T15:03:08.970907+00:00] $installerAlreadyRunningRetries++
[2025-08-28T15:03:08.971123+00:00] Start-Sleep -Seconds 60
[2025-08-28T15:03:08.971127+00:00] .$installCommandBlock
[2025-08-28T15:03:08.971132+00:00] }
[2025-08-28T15:03:08.971136+00:00] # If there are any errors in the package installation, we need to exit with a non-zero code
[2025-08-28T15:03:08.971139+00:00] if ($unitResultsObject.Status -ne "Ok") {
[2025-08-28T15:03:08.971143+00:00] Write-Error "There were errors installing the package."
[2025-08-28T15:03:08.971147+00:00] exit 1
[2025-08-28T15:03:08.971151+00:00] }
[2025-08-28T15:03:08.971154+00:00] }
[2025-08-28T15:03:08.971156+00:00] else {
[2025-08-28T15:03:08.971161+00:00] Write-Host "Couldn't find output file for package installation, assuming fail."
[2025-08-28T15:03:08.971165+00:00] exit 1
[2025-08-28T15:03:08.971169+00:00] }
[2025-08-28T15:03:08.971178+00:00] : Failed to install package. Exit code: 1.
[2025-08-28T15:03:08.971182+00:00] At C:\Windows\SystemTemp\6ad90cc0-8925-44b4-8f9b-a3d55160f5b9\siuxmonv.jep\Invoke-Winget.ps1:364 char:5
[2025-08-28T15:03:08.971186+00:00] + .$installCommandBlock
[2025-08-28T15:03:08.971189+00:00] + ~~~~~~~~~~~~~~~~~~~~~
[2025-08-28T15:03:08.971193+00:00] + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
[2025-08-28T15:03:08.971197+00:00] + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException
[2025-08-28T15:03:08.971200+00:00]
[2025-08-28T15:03:08.985609+00:00]
[2025-08-28T15:03:08.985816+00:00]