Allow the addition of custom PowerShell profiles
This commit is contained in:
parent
a760b08537
commit
ada9df8e20
1 changed files with 16 additions and 0 deletions
|
@ -34,6 +34,22 @@ class Context {
|
||||||
Get-PinnedItem -Type TaskBar | Where-Object { $_.Name -like "$pattern" } | Remove-PinnedItem;
|
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() {
|
[Microsoft.Win32.RegistryKey] EnsureConfigKey() {
|
||||||
if (-not (Test-Path $this.ConfigRoot)) {
|
if (-not (Test-Path $this.ConfigRoot)) {
|
||||||
$null = New-Item $this.ConfigRoot;
|
$null = New-Item $this.ConfigRoot;
|
||||||
|
|
Loading…
Reference in a new issue