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

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;
}
};