diff --git a/scripts/Common/Config/powershell/lib.ps1 b/scripts/Common/Config/powershell/lib.ps1 index cbdc532f..68f4e0ea 100644 --- a/scripts/Common/Config/powershell/lib.ps1 +++ b/scripts/Common/Config/powershell/lib.ps1 @@ -4,9 +4,12 @@ $null = New-Module { param ( [Parameter(ParameterSetName="Global", Mandatory)] [switch]$System, + [Parameter(ParameterSetName="DefaultUser", Mandatory)] + [switch]$DefaultUser, [Parameter(ParameterSetName="Home")] [string]$HomeDir = "~", [Parameter(ParameterSetName="Global", Mandatory)] + [Parameter(ParameterSetName="DefaultUser")] [Parameter(ParameterSetName="Home")] [string]$Category = $null, [Parameter(Position=0, Mandatory=$true)] @@ -29,6 +32,14 @@ $null = New-Module { } else { [System.Collections.Generic.List[string]] $shells = @(); + if ($DefaultUser) { + if ($IsWindows) { + $HomeDir = "C:/Users/Default"; + } else { + $HomeDir = "/etc/skel" + } + } + if (Get-Command pwsh -ErrorAction SilentlyContinue) { $shells.Add("pwsh"); } @@ -44,6 +55,21 @@ $null = New-Module { Push-Location ~; $profiles = $profiles | ForEach-Object { [System.IO.Path]::GetRelativePath($(Get-Location), $_); }; + + $profiles | ForEach-Object { + $fileName = "$HomeDir/$_"; + $dirName = Split-Path -Parent $fileName; + + if (-not (Test-Path -PathType Container $dirName)) { + $null = New-Item -ItemType Directory -Force $dirName; + } + + if ((Test-Path -PathType Leaf $fileName) -and (-not $Overwrite)) { + Add-Content -Force "$fileName" "`n$Statement"; + } else { + Set-Content -Force "$fileName" "$Statement"; + } + }; } if ($Category) { @@ -54,21 +80,6 @@ $null = New-Module { $profiles = $profiles | ForEach-Object { Join-Path (Split-Path -Parent $_) "conf.d" "$Category.ps1"; }; } - $profiles | ForEach-Object { - $fileName = "$HomeDir/$_"; - $dirName = Split-Path -Parent $fileName; - - if (-not (Test-Path -PathType Container $dirName)) { - $null = New-Item -ItemType Directory -Force $dirName; - } - - if ((Test-Path -PathType Leaf $fileName) -and (-not $Overwrite)) { - Add-Content -Force "$fileName" "`n$Statement"; - } else { - Set-Content -Force "$fileName" "$Statement"; - } - }; - Pop-Location; }