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

61 lines
1.8 KiB
PowerShell

param (
$Action,
[hashtable] $Arguments
)
. "$PSScriptRoot/../../../Windows/Scripts/Software.ps1";
. "$PSScriptRoot/../../../Windows/Scripts/Scripting.ps1";
. "$PSScriptRoot/../../../Windows/Types/InstallerAction.ps1";
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"';
}
[System.Collections.ArrayList] $files = @($PROFILE);
if (Test-Command powershell) {
$null = $files.Add((powershell -c '$PROFILE'));
}
foreach ($file in $files) {
if (-not ((Test-Path -PathType Leaf $file) -and ((Get-Content $file) -contains $indicator))) {
Write-PSScript -FileName $file -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;
}
}
};