From 985661a91e2a27b0c133f239df278f2644d1c9d1 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 1 Aug 2024 21:06:03 +0200 Subject: [PATCH] Display the software name during installation --- scripts/Windows/Scripts/Software.ps1 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/scripts/Windows/Scripts/Software.ps1 b/scripts/Windows/Scripts/Software.ps1 index 22f2bc8c..d00f66e9 100644 --- a/scripts/Windows/Scripts/Software.ps1 +++ b/scripts/Windows/Scripts/Software.ps1 @@ -9,6 +9,20 @@ enum InstallerAction { $null = New-Module { $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 Installs the software. @@ -41,9 +55,19 @@ $null = New-Module { [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))) { + Write-Host "Installing $softwareName…"; Install-Software @Arguments; } elseif ($action -eq ([InstallerAction]::Configure)) { + Write-Host "Configuring $softwareName…"; Set-SoftwareConfiguration @Arguments; foreach ($user in Get-Users) { @@ -56,6 +80,7 @@ $null = New-Module { $Arguments.Add($userArgument, ($env:UserName)); } + Write-Host "Configuring $softwareName for user ``$($Arguments[$userArgument])``…"; Set-SoftwareUserConfiguration @Arguments; } }