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

35 lines
898 B
PowerShell
Raw Normal View History

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