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

36 lines
1.2 KiB
PowerShell
Raw Permalink Normal View History

. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
2024-10-13 13:35:24 +00:00
. "$PSScriptRoot/../../../Common/Software/powershell/Module.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));
}
$context = $parameters.context;
$context.Add("Installer", $parameters.installer);
Start-SoftwareInstaller -Force @args @parameters -Installer {
param(
[hashtable] $Context
)
$providerName = "NuGet";
$module = $Context.Name;
if ({ $null = powershell -c "Get-PackageProvider -ListAvailable $providerName"; $? }) {
2024-09-30 03:00:42 +00:00
$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;
}
}
}