From 2a7e0b643e56f635c5e9b5601842933703843cda Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 27 Jul 2023 02:05:56 +0200 Subject: [PATCH] Only load profile files if existent --- scripts/Windows/Config/PowerShell/Install.ps1 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/Windows/Config/PowerShell/Install.ps1 b/scripts/Windows/Config/PowerShell/Install.ps1 index 33a7f417..511b4873 100644 --- a/scripts/Windows/Config/PowerShell/Install.ps1 +++ b/scripts/Windows/Config/PowerShell/Install.ps1 @@ -5,4 +5,10 @@ param($context) Write-Host "Configuring PowerShell"; Write-Information "Allow addition of any number of profile files"; [Context] $context = $context; -$context.AddPowerShellProfileStatement('. "$PSScriptRoot/profile.d/*.ps1";'); + +$context.AddPowerShellProfileStatement( + @( + '$profilePath = "$PSScriptRoot/profile.d/*.ps1";', + 'if (Test-Path $profilePath) {', + ' . $profilePath;', + '}') -join ([System.Environment]::NewLine));