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

44 lines
1.3 KiB
PowerShell

param (
$Action,
[hashtable] $Arguments
)
. "$PSScriptRoot/../../Scripts/Software.ps1";
. "$PSScriptRoot/../../Software/PowerShell/Profile.ps1";
. "$PSScriptRoot/../../Types/InstallerAction.ps1";
Start-SoftwareInstaller @PSBoundParameters `
-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;
}
};