From cc84c185afb0880288e21bd205b02cfb32e4a24a Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 8 Aug 2024 22:24:41 +0200 Subject: [PATCH] Suppress unnecessary output --- scripts/Common/Scripts/Software.ps1 | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/scripts/Common/Scripts/Software.ps1 b/scripts/Common/Scripts/Software.ps1 index de4141b6..a191d715 100644 --- a/scripts/Common/Scripts/Software.ps1 +++ b/scripts/Common/Scripts/Software.ps1 @@ -196,9 +196,9 @@ $null = New-Module { function Start-SoftwareInstaller { param( [string] $Name, - [scriptblock] $Installer = { }, - [scriptblock] $Configurator = { }, - [scriptblock] $UserConfigurator = { }, + [scriptblock] $Installer = $null, + [scriptblock] $Configurator = $null, + [scriptblock] $UserConfigurator = $null, [Nullable[InstallerAction]] $Action, [hashtable] $Arguments ) @@ -236,12 +236,16 @@ $null = New-Module { }; if ($action -eq ([InstallerAction]::Install)) { - Write-Host "Installing $Name…"; - & $Installer @argumentList; + if ($Installer) { + Write-Host "Installing $Name…"; + & $Installer @argumentList; + } # ToDo: Automatically configure after installation } elseif ($Action -eq ([InstallerAction]::Configure)) { - Write-Host "Configuring $Name…"; - & $Configurator @argumentList; + if ($Configurator) { + Write-Host "Configuring $Name…"; + & $Configurator @argumentList; + } if (-not (Test-SetupUser)) { $argumentList.Add("action", [InstallerAction]::ConfigureUser); @@ -252,8 +256,10 @@ $null = New-Module { $argumentList.Add($userArgument, ($env:UserName)); } - Write-Host "Configuring $Name for user ``$($Arguments[$userArgument])``…"; - & $UserConfigurator @argumentList; + if ($UserConfigurator) { + Write-Host "Configuring $Name for user ``$($Arguments[$userArgument])``…"; + & $UserConfigurator @argumentList; + } } };