Add scripts for installing PowerShell
This commit is contained in:
parent
26ef9a12b9
commit
36336e332d
4 changed files with 129 additions and 0 deletions
scripts/Common/Software/PowerShell
60
scripts/Common/Software/PowerShell/Manage.ps1
Normal file
60
scripts/Common/Software/PowerShell/Manage.ps1
Normal file
|
@ -0,0 +1,60 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue