From 516a340ced1f779780161cf6c9eae135984242fa Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 1 Aug 2024 18:24:26 +0200 Subject: [PATCH] Add a script for managing software --- scripts/Windows/Scripts/Software.ps1 | 62 ++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 scripts/Windows/Scripts/Software.ps1 diff --git a/scripts/Windows/Scripts/Software.ps1 b/scripts/Windows/Scripts/Software.ps1 new file mode 100644 index 00000000..f17a30ec --- /dev/null +++ b/scripts/Windows/Scripts/Software.ps1 @@ -0,0 +1,62 @@ +. "$PSScriptRoot/Config.ps1"; + +enum InstallerAction { + Install + Configure + ConfigureUser +} + +$null = New-Module { + $userArgument = "name"; + + <# + .SYNOPSIS + Installs the software. + #> + function Install-Software { } + + <# + .SYNOPSIS + Configures the system for the software. + #> + function Set-SoftwareConfiguration { } + + <# + .SYNOPSIS + Configures a user for the software. + + .PARAMETER Name + The name of the user to configure. + #> + function Set-SoftwareUserConfiguration { + param( + [Parameter(Mandatory = $true)] + [string] $Name + ) + } + + function Start-SoftwareInstaller { + param( + [InstallerAction] $Action, + [hashtable] $Arguments + ) + + if (($null -eq $Action) -or ($action -eq ([InstallerAction]::Install))) { + Install-Software @Arguments; + } elseif ($action -eq ([InstallerAction]::Configure)) { + Set-SoftwareConfiguration @Arguments; + + foreach ($user in Get-Users) { + $Arguments.Add($userArgument, $user); + + Start-SoftwareInstaller -Action ([InstallerAction]::ConfigureUser) @Arguments; + } + } elseif ($action -eq ([InstallerAction]::ConfigureUser)) { + if ((-not $Arguments.Contains($userArgument)) -or ($null -eq $Arguments[$userArgument])) { + $Arguments.Add($userArgument, ($env:UserName)); + } + + Set-SoftwareUserConfiguration @Arguments; + } + } +}