Allow installing PowerShell scripts for the default user
This commit is contained in:
parent
0481482f23
commit
9918465b27
1 changed files with 26 additions and 15 deletions
|
@ -4,9 +4,12 @@ $null = New-Module {
|
||||||
param (
|
param (
|
||||||
[Parameter(ParameterSetName="Global", Mandatory)]
|
[Parameter(ParameterSetName="Global", Mandatory)]
|
||||||
[switch]$System,
|
[switch]$System,
|
||||||
|
[Parameter(ParameterSetName="DefaultUser", Mandatory)]
|
||||||
|
[switch]$DefaultUser,
|
||||||
[Parameter(ParameterSetName="Home")]
|
[Parameter(ParameterSetName="Home")]
|
||||||
[string]$HomeDir = "~",
|
[string]$HomeDir = "~",
|
||||||
[Parameter(ParameterSetName="Global", Mandatory)]
|
[Parameter(ParameterSetName="Global", Mandatory)]
|
||||||
|
[Parameter(ParameterSetName="DefaultUser")]
|
||||||
[Parameter(ParameterSetName="Home")]
|
[Parameter(ParameterSetName="Home")]
|
||||||
[string]$Category = $null,
|
[string]$Category = $null,
|
||||||
[Parameter(Position=0, Mandatory=$true)]
|
[Parameter(Position=0, Mandatory=$true)]
|
||||||
|
@ -29,6 +32,14 @@ $null = New-Module {
|
||||||
} else {
|
} else {
|
||||||
[System.Collections.Generic.List[string]] $shells = @();
|
[System.Collections.Generic.List[string]] $shells = @();
|
||||||
|
|
||||||
|
if ($DefaultUser) {
|
||||||
|
if ($IsWindows) {
|
||||||
|
$HomeDir = "C:/Users/Default";
|
||||||
|
} else {
|
||||||
|
$HomeDir = "/etc/skel"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Get-Command pwsh -ErrorAction SilentlyContinue) {
|
if (Get-Command pwsh -ErrorAction SilentlyContinue) {
|
||||||
$shells.Add("pwsh");
|
$shells.Add("pwsh");
|
||||||
}
|
}
|
||||||
|
@ -44,15 +55,6 @@ $null = New-Module {
|
||||||
|
|
||||||
Push-Location ~;
|
Push-Location ~;
|
||||||
$profiles = $profiles | ForEach-Object { [System.IO.Path]::GetRelativePath($(Get-Location), $_); };
|
$profiles = $profiles | ForEach-Object { [System.IO.Path]::GetRelativePath($(Get-Location), $_); };
|
||||||
}
|
|
||||||
|
|
||||||
if ($Category) {
|
|
||||||
if (-not $($Overwrite.IsPresent)) {
|
|
||||||
$Overwrite = $true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$profiles = $profiles | ForEach-Object { Join-Path (Split-Path -Parent $_) "conf.d" "$Category.ps1"; };
|
|
||||||
}
|
|
||||||
|
|
||||||
$profiles | ForEach-Object {
|
$profiles | ForEach-Object {
|
||||||
$fileName = "$HomeDir/$_";
|
$fileName = "$HomeDir/$_";
|
||||||
|
@ -68,6 +70,15 @@ $null = New-Module {
|
||||||
Set-Content -Force "$fileName" "$Statement";
|
Set-Content -Force "$fileName" "$Statement";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Category) {
|
||||||
|
if (-not $($Overwrite.IsPresent)) {
|
||||||
|
$Overwrite = $true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$profiles = $profiles | ForEach-Object { Join-Path (Split-Path -Parent $_) "conf.d" "$Category.ps1"; };
|
||||||
|
}
|
||||||
|
|
||||||
Pop-Location;
|
Pop-Location;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue