Suppress unnecessary output

This commit is contained in:
Manuel Thalmann 2024-08-08 22:24:41 +02:00
parent 5d7022f981
commit d86d27e8de

View file

@ -196,9 +196,9 @@ $null = New-Module {
function Start-SoftwareInstaller { function Start-SoftwareInstaller {
param( param(
[string] $Name, [string] $Name,
[scriptblock] $Installer = { }, [scriptblock] $Installer = $null,
[scriptblock] $Configurator = { }, [scriptblock] $Configurator = $null,
[scriptblock] $UserConfigurator = { }, [scriptblock] $UserConfigurator = $null,
[Nullable[InstallerAction]] $Action, [Nullable[InstallerAction]] $Action,
[hashtable] $Arguments [hashtable] $Arguments
) )
@ -236,12 +236,16 @@ $null = New-Module {
}; };
if ($action -eq ([InstallerAction]::Install)) { if ($action -eq ([InstallerAction]::Install)) {
if ($Installer) {
Write-Host "Installing $Name"; Write-Host "Installing $Name";
& $Installer @argumentList; & $Installer @argumentList;
}
# ToDo: Automatically configure after installation # ToDo: Automatically configure after installation
} elseif ($Action -eq ([InstallerAction]::Configure)) { } elseif ($Action -eq ([InstallerAction]::Configure)) {
if ($Configurator) {
Write-Host "Configuring $Name"; Write-Host "Configuring $Name";
& $Configurator @argumentList; & $Configurator @argumentList;
}
if (-not (Test-SetupUser)) { if (-not (Test-SetupUser)) {
$argumentList.Add("action", [InstallerAction]::ConfigureUser); $argumentList.Add("action", [InstallerAction]::ConfigureUser);
@ -252,9 +256,11 @@ $null = New-Module {
$argumentList.Add($userArgument, ($env:UserName)); $argumentList.Add($userArgument, ($env:UserName));
} }
if ($UserConfigurator) {
Write-Host "Configuring $Name for user ``$($Arguments[$userArgument])``"; Write-Host "Configuring $Name for user ``$($Arguments[$userArgument])``";
& $UserConfigurator @argumentList; & $UserConfigurator @argumentList;
} }
}
}; };
& $installHandler -Action $Action -Arguments $Arguments; & $installHandler -Action $Action -Arguments $Arguments;