Display the software name during installation

This commit is contained in:
Manuel Thalmann 2024-08-01 21:06:03 +02:00
parent 1fcf4ef21e
commit edd9168b10

View file

@ -9,6 +9,20 @@ enum InstallerAction {
$null = New-Module { $null = New-Module {
$userArgument = "name"; $userArgument = "name";
<#
.SYNOPSIS
Gets the name of the software.
#>
function Get-SoftwareName {
$path = ${Function:Install-Software}.File;
if ($path -ne "$PSCommandPath") {
Split-Path -Leaf (Split-Path -Parent $path);
} else {
$null;
}
}
<# <#
.SYNOPSIS .SYNOPSIS
Installs the software. Installs the software.
@ -41,9 +55,19 @@ $null = New-Module {
[hashtable] $Arguments [hashtable] $Arguments
) )
$null = $softwareName;
if ($null -ne (Get-SoftwareName)) {
$softwareName = "``$(Get-SoftwareName)``";
} else {
$softwareName = "unknown software";
}
if (($null -eq $Action) -or ($action -eq ([InstallerAction]::Install))) { if (($null -eq $Action) -or ($action -eq ([InstallerAction]::Install))) {
Write-Host "Installing $softwareName";
Install-Software @Arguments; Install-Software @Arguments;
} elseif ($action -eq ([InstallerAction]::Configure)) { } elseif ($action -eq ([InstallerAction]::Configure)) {
Write-Host "Configuring $softwareName";
Set-SoftwareConfiguration @Arguments; Set-SoftwareConfiguration @Arguments;
foreach ($user in Get-Users) { foreach ($user in Get-Users) {
@ -56,6 +80,7 @@ $null = New-Module {
$Arguments.Add($userArgument, ($env:UserName)); $Arguments.Add($userArgument, ($env:UserName));
} }
Write-Host "Configuring $softwareName for user ``$($Arguments[$userArgument])``";
Set-SoftwareUserConfiguration @Arguments; Set-SoftwareUserConfiguration @Arguments;
} }
} }