diff --git a/scripts/Windows/Scripts/Context.ps1 b/scripts/Windows/Scripts/Context.ps1 index a20bdca6..2ecd02bb 100644 --- a/scripts/Windows/Scripts/Context.ps1 +++ b/scripts/Windows/Scripts/Context.ps1 @@ -34,6 +34,22 @@ class Context { Get-PinnedItem -Type TaskBar | Where-Object { $_.Name -like "$pattern" } | Remove-PinnedItem; } + [void] AddPowerShellProfileStatement([string] $statement) { + $this.AddPowerShellProfileStatement($null, $statement); + } + + [void] AddPowerShellProfileStatement([string] $category, [string] $statement) { + Push-Location ~; + $profileFiles = @((powershell -c '$PROFILE'), (pwsh -c '$PROFILE')) | ForEach-Object { Resolve-Path -Relative $_ }; + + if ($category) { + $profileFiles = $profileFiles | ForEach-Object { Join-Path (Split-Path -Parent $_) "profile.d" "$category.ps1"; }; + } + + $profileFiles | ForEach-Object { Add-Content "C:\Users\Default\$_" "`n$statement"; }; + Pop-Location; + } + [Microsoft.Win32.RegistryKey] EnsureConfigKey() { if (-not (Test-Path $this.ConfigRoot)) { $null = New-Item $this.ConfigRoot;