PortValhalla/scripts/Windows/Software/PinnedItem/Manage.ps1

36 lines
1 KiB
PowerShell
Raw Normal View History

2024-08-08 02:36:35 +00:00
param (
$Action,
[hashtable] $Arguments
)
. "$PSScriptRoot/../../../Common/Software/PowerShell/Module.ps1";
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
2024-08-08 02:36:35 +00:00
2024-08-22 21:55:41 +00:00
$parameters = Get-ModuleInstallerComponents "PinnedItem" -NativeOnly -NoProfile;
2024-08-08 02:36:35 +00:00
foreach ($key in $PSBoundParameters.Keys) {
$parameters.Add($key, $PSBoundParameters.TryGetValue($key));
}
$arguments = $parameters.arguments;
$arguments.Add("Installer", $parameters.installer);
Start-SoftwareInstaller @parameters -Installer {
param(
[scriptblock] $Installer,
[hashtable] $Arguments
)
$module = $Arguments.Name;
& $Arguments.Installer @PSBoundParameters;
if (-not (& { powershell -NoProfile -Command "Import-Module $module; exit ([bool]`$Error)" 2> $null; $?; })) {
$feature = "NetFx3";
if ((Get-WindowsOptionalFeature -Online -FeatureName $feature).State -ne "Enabled") {
Write-Host "Enabling ``$feature`` feature…";
choco install --source windowsFeatures -y $feature;
}
}
}