PortValhalla/scripts/Common/Software/PowerShell/Manage.ps1

39 lines
1.3 KiB
PowerShell
Raw Normal View History

2024-08-07 19:05:32 +00:00
. "$PSScriptRoot/../../Scripts/Software.ps1";
2024-08-07 19:34:40 +00:00
. "$PSScriptRoot/../../Software/PowerShell/Profile.ps1";
2024-08-07 19:05:32 +00:00
. "$PSScriptRoot/../../Types/InstallerAction.ps1";
2024-08-07 18:30:12 +00:00
2024-09-30 03:00:20 +00:00
Start-SoftwareInstaller @args `
2024-08-07 18:30:12 +00:00
-Configurator {
[string] $globalDir = $null;
$indicator = "# Profile Files";
2024-08-07 19:35:03 +00:00
if (-not $IsWindows) {
2024-08-07 18:30:12 +00:00
$globalDir = '"/etc/powershell/conf.d"';
} else {
$globalDir = '"$env:ProgramData/PowerShell/conf.d"';
}
2024-08-07 19:34:40 +00:00
if (-not ((Test-Path -PathType Leaf $PROFILE) -and ((Get-Content $PROFILE) -contains $indicator))) {
Add-PowerShellProfileStatement `
-DefaultUser `
-Script (@(
2024-08-07 19:35:03 +00:00
$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 { . $_; };
2024-08-07 18:30:12 +00:00
}
2024-08-07 19:35:03 +00:00
}
}).ToString()) -join "`n") `
-Append;
2024-08-07 18:30:12 +00:00
}
};