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

32 lines
927 B
PowerShell
Raw Normal View History

using namespace Microsoft.Win32;
2024-08-07 19:05:32 +00:00
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
2024-08-07 19:50:21 +00:00
. "$PSScriptRoot/../../../Common/Software/PowerShell/Profile.ps1";
2024-09-30 03:00:20 +00:00
Start-SoftwareInstaller @args `
-Configurator {
param([string] $Name)
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 "$Name" `
2024-08-07 19:50:21 +00:00
-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";
};