From a3b17d50a58b4e272204579001821b338e974b86 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Wed, 7 Aug 2024 21:35:03 +0200 Subject: [PATCH] Use internal OS detection --- scripts/Common/Software/PowerShell/Manage.ps1 | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/scripts/Common/Software/PowerShell/Manage.ps1 b/scripts/Common/Software/PowerShell/Manage.ps1 index 066b6312..7c56b4c7 100644 --- a/scripts/Common/Software/PowerShell/Manage.ps1 +++ b/scripts/Common/Software/PowerShell/Manage.ps1 @@ -16,14 +16,10 @@ Start-SoftwareInstaller @PSBoundParameters ` & $Installer -Action ([InstallerAction]::Configure); } ` -Configurator { - param( - [hashtable] $Arguments - ) - [string] $globalDir = $null; $indicator = "# Profile Files"; - if ($Arguments.Linux) { + if (-not $IsWindows) { $globalDir = '"/etc/powershell/conf.d"'; } else { $globalDir = '"$env:ProgramData/PowerShell/conf.d"'; @@ -33,22 +29,22 @@ Start-SoftwareInstaller @PSBoundParameters ` Add-PowerShellProfileStatement ` -DefaultUser ` -Script (@( - $indicator, - "`$globalDir = $globalDir", - ({ - $profileRoot = Split-Path -Parent $PROFILE; - - $profilePaths = @( - "$profileRoot/conf.d/*.ps1", - "$globalDir/*.ps1" - ) - - foreach ($profilePath in $profilePaths) { - if (Test-Path $profilePath) { - Get-Item $profilePath | ForEach-Object { . $_; }; - } + $indicator, + "`$globalDir = $globalDir", + ({ + $profileRoot = Split-Path -Parent $PROFILE; + + $profilePaths = @( + "$profileRoot/conf.d/*.ps1", + "$globalDir/*.ps1" + ) + + foreach ($profilePath in $profilePaths) { + if (Test-Path $profilePath) { + Get-Item $profilePath | ForEach-Object { . $_; }; } - }).ToString()) -join "`n") ` - -Append; + } + }).ToString()) -join "`n") ` + -Append; } };