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

36 lines
965 B
PowerShell

using namespace Microsoft.Win32;
param(
$Action,
[hashtable] $Arguments
)
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
. "$PSScriptRoot/../../../Common/Software/PowerShell/Profile.ps1";
Start-SoftwareInstaller @PSBoundParameters `
-Configurator {
[string] $backup = $null;
$nativeProfile = powershell -c '$PROFILE';
if (Test-Path -PathType Leaf $nativeProfile) {
$backup = "${nativeProfile}_";
Move-Item $nativeProfile $backup;
}
$null = New-Item -Force $nativeProfile;
choco install -y --force chocolatey;
Add-PowerShellProfileStatement `
-DefaultUser `
-Category "chocolatey" `
-Script (Get-Content $nativeProfile | Out-String) `
-Append;
if ($backup) {
Move-Item $backup $nativeProfile;
}
Import-Module "$env:ChocolateyInstall/helpers/chocolateyProfile.psm1";
};