PortValhalla/scripts/Common/Software/powershell/Main.ps1

40 lines
1.3 KiB
PowerShell
Raw Normal View History

2024-08-07 19:05:32 +00:00
. "$PSScriptRoot/../../Scripts/Software.ps1";
2024-10-13 13:35:24 +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"';
2024-10-06 19:25:34 +00:00
}
else {
2024-08-07 18:30:12 +00:00
$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-10-06 19:25:34 +00:00
$indicator,
"`$globalDir = $globalDir",
({
$profileRoot = Split-Path -Parent $PROFILE;
2024-08-07 19:35:03 +00:00
2024-10-06 19:25:34 +00:00
$profilePaths = @(
"$profileRoot/conf.d/*.ps1",
"$globalDir/*.ps1"
)
2024-08-07 19:35:03 +00:00
2024-10-06 19:25:34 +00:00
foreach ($profilePath in $profilePaths) {
if (Test-Path $profilePath) {
Get-Item $profilePath | ForEach-Object { . $_; };
}
2024-08-07 18:30:12 +00:00
}
2024-10-06 19:25:34 +00:00
}).ToString()) -join "`n") `
-Append;
2024-08-07 18:30:12 +00:00
}
2024-10-06 19:25:34 +00:00
};