diff --git a/scripts/Common/Scripts/Software.ps1 b/scripts/Common/Scripts/Software.ps1 index 4731f8c3..2b3a9625 100644 --- a/scripts/Common/Scripts/Software.ps1 +++ b/scripts/Common/Scripts/Software.ps1 @@ -15,7 +15,8 @@ $null = New-Module { [scriptblock] $UserBackup = $null, [scriptblock] $UserConfigurator = $null, [Nullable[InstallerAction]] $Action, - [hashtable] $Arguments + [hashtable] $Arguments, + [hashtable] $Context ) [InstallerAction] $Action = & { @@ -35,7 +36,8 @@ $null = New-Module { param( [string] $Name, [InstallerAction] $Action, - [hashtable] $Arguments + [hashtable] $Arguments, + [hashtable] $Context ) [string] $DisplayName = $null; @@ -47,11 +49,13 @@ $null = New-Module { } $Arguments ??= @{ }; + $Context ??= @{ }; $argumentList = @{ name = $Name; installer = $installHandler; arguments = $Arguments; + context = $Context; }; switch ($Action) { @@ -105,7 +109,7 @@ $null = New-Module { } }; - & $installHandler -Name $Name -Action $Action -Arguments $Arguments; + & $installHandler -Name $Name -Action $Action -Arguments $Arguments -Context $Context; }; } } diff --git a/scripts/Common/Software/PowerShell/Module.ps1 b/scripts/Common/Software/PowerShell/Module.ps1 index 37c6fef6..bfec097f 100644 --- a/scripts/Common/Software/PowerShell/Module.ps1 +++ b/scripts/Common/Software/PowerShell/Module.ps1 @@ -24,16 +24,16 @@ $null = New-Module { ) @{ - arguments = @{ + context = @{ name = $Name; nativeOnly = $NativeOnly; }; installer = { param( - [hashtable] $Arguments + [hashtable] $Context ) - $env:PENDING_MODULE_NAME = $Arguments.Name; + $env:PENDING_MODULE_NAME = $Context.Name; $installAction = { $module = $env:PENDING_MODULE_NAME; @@ -43,7 +43,7 @@ $null = New-Module { } }; - if (-not $Arguments.NativeOnly) { + if (-not $Context.NativeOnly) { & $installAction -AcceptLicense; } @@ -56,10 +56,10 @@ $null = New-Module { configurator = ($NoProfile.IsPresent) ? { } : { param( - [hashtable] $Arguments + [hashtable] $Context ) - $name = $Arguments.Name; + $name = $Context.Name; Add-PowerShellProfileStatement ` -System ` diff --git a/scripts/Windows/Software/PinnedItem/Manage.ps1 b/scripts/Windows/Software/PinnedItem/Manage.ps1 index 7631a130..1ab841aa 100644 --- a/scripts/Windows/Software/PinnedItem/Manage.ps1 +++ b/scripts/Windows/Software/PinnedItem/Manage.ps1 @@ -12,22 +12,22 @@ foreach ($key in $PSBoundParameters.Keys) { $parameters.Add($key, $PSBoundParameters.TryGetValue($key)); } -$arguments = $parameters.arguments; -$arguments.Add("Installer", $parameters.installer); +$context = $parameters.context; +$context.Add("Installer", $parameters.installer); Start-SoftwareInstaller @parameters -Installer { param( - [hashtable] $Arguments + [hashtable] $Context ) $providerName = "NuGet"; - $module = $Arguments.Name; + $module = $Context.Name; if ({ $null = powershell -c "Get-PackageProvider -ListAvailable $providerName"; $? }) { $null = powershell -c "Install-PackageProvider -Force $providerName"; } - & $Arguments.Installer @PSBoundParameters; + & $Context.Installer @PSBoundParameters; if (-not (& { powershell -NoProfile -Command "Import-Module $module; exit ([bool]`$Error)" 2> $null; $?; })) { $feature = "NetFx3"; diff --git a/scripts/Windows/Software/TrackMania United Forever/Manage.ps1 b/scripts/Windows/Software/TrackMania United Forever/Manage.ps1 index 64c4f3a0..8f99c6f3 100644 --- a/scripts/Windows/Software/TrackMania United Forever/Manage.ps1 +++ b/scripts/Windows/Software/TrackMania United Forever/Manage.ps1 @@ -19,14 +19,14 @@ function Get-TMForeverInstallerComponents { ) @{ - arguments = @{ + context = @{ iconName = $IconName; userDirectory = $UserDirectory; installer = $Installer; }; installer = { - param([hashtable] $Arguments) - $iconName = $Arguments.IconName; + param([hashtable] $Context) + $iconName = $Context.IconName; foreach ($feature in @("DirectPlay", "NetFx3")) { if ((Get-WindowsOptionalFeature -Online -FeatureName $feature).State -ne "Enabled") { @@ -35,16 +35,16 @@ function Get-TMForeverInstallerComponents { } } - & $Arguments.Installer; + & $Context.Installer; Remove-DesktopIcon "*$iconName*"; }; userBackup = { param( [string] $Name, - [hashtable] $Arguments + [hashtable] $Context ) - Add-BackupArtifacts -User $Arguments.Name -Source $Arguments.UserDirectory -Path "$Name" ` + Add-BackupArtifacts -User $Context.Name -Source $Context.UserDirectory -Path "$Name" ` -Include @( "ChallengeMusics", "MediaTracker", @@ -58,10 +58,10 @@ function Get-TMForeverInstallerComponents { userConfigurator = { param( [string] $Name, - [hashtable] $Arguments + [hashtable] $Context ) - $user = $Arguments.Name; + $user = $Context.Name; Expand-BackupArtifacts -User $user -Path "$Name" -Target $path; }; };