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

55 lines
1.6 KiB
PowerShell
Raw Normal View History

2024-08-07 18:30:12 +00:00
param (
$Action,
[hashtable] $Arguments
)
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
Start-SoftwareInstaller @PSBoundParameters `
-Installer {
param(
[scriptblock] $Installer
)
& $Installer -Action ([InstallerAction]::Configure);
} `
-Configurator {
param(
[hashtable] $Arguments
)
[string] $globalDir = $null;
$indicator = "# Profile Files";
if ($Arguments.Linux) {
$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 18:30:12 +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 { . $_; };
}
}
}).ToString()) -join "`n") `
-Append;
}
};