From d9be9fe3dad8db7dbc7ac7ab8ae62576ba45df78 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 f17a30ec..151f98f3 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. @@ -40,10 +54,20 @@ $null = New-Module { [InstallerAction] $Action, [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; } }