Allow global installation of powershell configs

This commit is contained in:
Manuel Thalmann 2024-03-20 23:49:21 +01:00
parent cdfbf46282
commit dab33f679b
2 changed files with 41 additions and 28 deletions
scripts/Windows/Scripts

View file

@ -44,34 +44,30 @@ class Context {
$this.AddPowerShellProfileStatement($true, $category, $statement);
}
[void] AddPowerShellProfileStatement([bool] $defaultUser, [string] $statement) {
$this.AddPowerShellProfileStatement($defaultUser, $null, $statement);
[void] AddPowerShellProfileStatement([bool] $system, [string] $statement) {
$this.AddPowerShellProfileStatement($system, $null, $statement);
}
[void] AddPowerShellProfileStatement([bool] $defaultUser, [string] $category, [string] $statement) {
[string] $homeDir = $null;
if ($defaultUser) {
$homeDir = "C:\Users\Default";
} else {
$homeDir = "~";
}
$this.AddPowerShellProfileStatement($homeDir, $category, $statement);
[void] AddPowerShellProfileStatement([bool] $system, [string] $category, [string] $statement) {
$this.AddPowerShellProfileStatement($system, $category, $statement);
}
[void] AddPowerShellProfileStatement([string] $homeDir, [string] $category, [string] $statement) {
[void] AddPowerShellProfileStatement([bool] $system, [string] $category, [string] $statement) {
if ($category) {
$overwrite = $true;
} else {
$overwrite = $false;
}
$this.AddPowerShellProfileStatement($homeDir, $category, $statement, $overwrite);
$this.AddPowerShellProfileStatement($system, $category, $statement, $overwrite);
}
[void] AddPowerShellProfileStatement([string] $homeDir, [string] $category, [string] $statement, [bool] $overwrite) {
Add-PowerShellProfileStatement -HomeDir $homeDir -Category $category -Statement $statement -Overwrite $overwrite;
[void] AddPowerShellProfileStatement([bool] $system, [string] $category, [string] $statement, [bool] $overwrite) {
if ($system) {
Add-PowerShellProfileStatement -System -Category $category -Statement $statement -Overwrite $overwrite;
} else {
Add-PowerShellProfileStatement -Category $category -Statement $statement -Overwrite $overwrite;
}
}
[Microsoft.Win32.RegistryKey] EnsureConfigKey() {