PortValhalla/scripts/Windows/Software/pinned-item/Main.ps1

36 lines
1.2 KiB
PowerShell

. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
. "$PSScriptRoot/../../../Common/Software/powershell/Module.ps1";
$parameters = Get-ModuleInstallerComponents "PinnedItem" -NativeOnly -NoProfile;
foreach ($key in $PSBoundParameters.Keys) {
$parameters.Add($key, $PSBoundParameters.TryGetValue($key));
}
$context = $parameters.context;
$context.Add("Installer", $parameters.installer);
Start-SoftwareInstaller @args @parameters -Installer {
param(
[hashtable] $Context
)
$providerName = "NuGet";
$module = $Context.Name;
if ({ $null = powershell -c "Get-PackageProvider -ListAvailable $providerName"; $? }) {
$null = powershell -c "Install-PackageProvider -Force $providerName -Scope AllUsers";
}
& $Context.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;
}
}
}