. "$PSScriptRoot/Config.ps1"; . "$PSScriptRoot/../Types/InstallerAction.ps1"; <# .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. #> 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 ) } $null = New-Module { . "$PSScriptRoot/../Types/InstallerAction.ps1"; $userArgument = "name"; function Start-SoftwareInstaller { param( [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) { $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)); } Write-Host "Configuring $softwareName for user ``$($Arguments[$userArgument])``…"; Set-SoftwareUserConfiguration @Arguments; } } }