PortValhalla/scripts/Common/Software/PowerShell/Manage.ps1
2024-10-06 21:25:34 +02:00

40 lines
1.3 KiB
PowerShell

. "$PSScriptRoot/../../Scripts/Software.ps1";
. "$PSScriptRoot/../../Software/PowerShell/Profile.ps1";
. "$PSScriptRoot/../../Types/InstallerAction.ps1";
Start-SoftwareInstaller @args `
-Configurator {
[string] $globalDir = $null;
$indicator = "# Profile Files";
if (-not $IsWindows) {
$globalDir = '"/etc/powershell/conf.d"';
}
else {
$globalDir = '"$env:ProgramData/PowerShell/conf.d"';
}
if (-not ((Test-Path -PathType Leaf $PROFILE) -and ((Get-Content $PROFILE) -contains $indicator))) {
Add-PowerShellProfileStatement `
-DefaultUser `
-Script (@(
$indicator,
"`$globalDir = $globalDir",
({
$profileRoot = Split-Path -Parent $PROFILE;
$profilePaths = @(
"$profileRoot/conf.d/*.ps1",
"$globalDir/*.ps1"
)
foreach ($profilePath in $profilePaths) {
if (Test-Path $profilePath) {
Get-Item $profilePath | ForEach-Object { . $_; };
}
}
}).ToString()) -join "`n") `
-Append;
}
};