Skip to content

Commit 8b4c088

Browse files
authored
winget and git-clone tasks: run winget install in silent mode (#123)
* add -Mode Silent to Winget task * add it to git-clone task as well * also use winget install --silent
1 parent 891aee6 commit 8b4c088

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Tasks/git-clone/main.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,9 @@ function InstallPackage{
266266
# if winget is available, use it to install package
267267
if (Get-Command winget -ErrorAction SilentlyContinue) {
268268
Write-Host "Installing $PackageId with winget"
269-
winget install --id $PackageId -e --source winget
269+
winget install --id $PackageId -e --source winget --silent
270270
$installExitCode = $LASTEXITCODE
271-
Write-Host "'winget install --id $PackageId -e --source winget' exited with code: $($installExitCode)"
271+
Write-Host "'winget install --id $PackageId -e --source winget --silent' exited with code: $($installExitCode)"
272272
if ($installExitCode -eq 0) {
273273
# add package path to path
274274
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") + ";" + $PackagePath
@@ -296,7 +296,7 @@ function InstallPackage{
296296
$tempOutFile = [System.IO.Path]::GetTempFileName() + ".out.json"
297297

298298
$installCommandBlock = {
299-
$installPackageCommand = "Install-WinGetPackage -Scope $($scopeFlagValue) -Source winget -Id $($PackageId) | ConvertTo-Json -Depth 10 | Tee-Object -FilePath '$($tempOutFile)'"
299+
$installPackageCommand = "Install-WinGetPackage -Scope $($scopeFlagValue) -Mode Silent -Source winget -Id $($PackageId) | ConvertTo-Json -Depth 10 | Tee-Object -FilePath '$($tempOutFile)'"
300300
$processCreation = Invoke-CimMethod -ClassName Win32_Process -MethodName Create -Arguments @{CommandLine="C:\Program Files\PowerShell\7\pwsh.exe $($mtaFlag) -Command `"$($installPackageCommand)`""}
301301
if (!($processCreation) -or !($processCreation.ProcessId)) {
302302
Write-Error "Failed to install $PackageId package. Process creation failed."

Tasks/winget/main.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ if ($RunAsUser -eq "true") {
337337
$versionFlag = "--version `"$($Version)`""
338338
}
339339
Write-Host "Appending package install: $($Package)"
340-
AppendToUserScript "winget install --id `"$($Package)`" $($versionFlag) --accept-source-agreements --accept-package-agreements"
340+
AppendToUserScript "winget install --id `"$($Package)`" $($versionFlag) --accept-source-agreements --accept-package-agreements --silent"
341341
AppendToUserScript "Write-Host `"winget exit code: `$LASTEXITCODE`""
342342
}
343343
# We're running in configuration file mode:
@@ -373,7 +373,7 @@ else {
373373
}
374374

375375
$installCommandBlock = {
376-
$installPackageCommand = "Install-WinGetPackage -Scope $($scopeFlagValue) -Source winget -Id '$($Package)' $($versionFlag) | ConvertTo-Json -Depth 10 | Tee-Object -FilePath '$($tempOutFile)'"
376+
$installPackageCommand = "Install-WinGetPackage -Scope $($scopeFlagValue) -Mode Silent -Source winget -Id '$($Package)' $($versionFlag) | ConvertTo-Json -Depth 10 | Tee-Object -FilePath '$($tempOutFile)'"
377377
$processCreation = Invoke-CimMethod -ClassName Win32_Process -MethodName Create -Arguments @{CommandLine="C:\Program Files\PowerShell\7\pwsh.exe $($mtaFlag) -Command `"$($installPackageCommand)`""}
378378
if (!($processCreation) -or !($processCreation.ProcessId)) {
379379
Write-Error "Failed to install package. Process creation failed."

0 commit comments

Comments
 (0)