Skip to content

Commit d9da6f2

Browse files
authored
Fixing some small winget errors. (#13)
1 parent 1482b8c commit d9da6f2

File tree

2 files changed

+37
-12
lines changed

2 files changed

+37
-12
lines changed

Scripts/Deploy.ps1

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -222,18 +222,43 @@ foreach ($step in $deploymentSteps) {
222222
$scriptAvailable = Get-DeploymentScript -ScriptName $step.ScriptName -LocalPath $localPath
223223

224224
if ($scriptAvailable) {
225-
$argumentList = "-ExecutionPolicy Bypass -File `"$localPath`""
226225
try {
227-
$proc = Start-Process pwsh -ArgumentList $argumentList -Wait -NoNewWindow -PassThru
228-
if ($proc.ExitCode -ne 0) {
229-
Write-Warning "$($step.Name) completed with errors (Exit Code: $($proc.ExitCode))"
230-
$allSuccessful = $false
226+
# Special handling for RMM Agent - run async and check indicators
227+
if ($step.ScriptName -eq "Install-RMMAgent.ps1") {
228+
Write-Output "Starting RMM Agent installation (async)..."
229+
$job = Start-Job -ScriptBlock {
230+
param($scriptPath)
231+
& $scriptPath
232+
} -ArgumentList $localPath
233+
234+
# Wait max 30 seconds for job to complete
235+
$timeout = 30
236+
$elapsed = 0
237+
while ($job.State -eq 'Running' -and $elapsed -lt $timeout) {
238+
Start-Sleep -Seconds 1
239+
$elapsed++
240+
}
241+
242+
# Check if job completed
243+
if ($job.State -eq 'Running') {
244+
Write-Output "RMM installation continuing in background..."
245+
Remove-Job $job -Force
246+
} else {
247+
$jobResult = Receive-Job $job
248+
$jobResult | ForEach-Object { Write-Output $_ }
249+
Remove-Job $job
250+
}
251+
} else {
252+
# Normal execution for all other scripts
253+
& $localPath
254+
if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
255+
Write-Warning "$($step.Name) completed with errors (Exit Code: $LASTEXITCODE)"
256+
$allSuccessful = $false
257+
}
231258
}
232259
} catch {
233-
if ($proc -and !$proc.HasExited) {
234-
Stop-Process -Id $proc.Id -Force
235-
}
236-
throw
260+
Write-Warning "$($step.Name) failed: $_"
261+
$allSuccessful = $false
237262
}
238263
} else {
239264
Write-Warning "Skipping $($step.Name) - script unavailable"
@@ -278,4 +303,4 @@ if ($allSuccessful) {
278303
Write-Output "Some deployment steps failed. Please review the output above."
279304
}
280305
Write-Output ""
281-
Read-Host "Press Enter to exit"
306+
Read-Host "Press Enter to exit"

Scripts/Deployment/Install-Applications.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ try {
2929
"Microsoft.Teams",
3030
"Microsoft.OneDrive",
3131
"7zip.7zip",
32-
"Microsoft.WindowsApp",
33-
"Microsoft.CompanyPortal"
32+
"Microsoft.WindowsApp"
33+
#"Microsoft.CompanyPortal" - Problematic package at this moment. Microsoft messed up the package. Use msstore version below instead. (exit code -2147024894)
3434
)
3535

3636
#Note: Some applications fail to install. This is why we have a separate list for msstore apps.

0 commit comments

Comments
 (0)