Only load profile files if existent

This commit is contained in:
Manuel Thalmann 2023-07-27 02:05:56 +02:00
parent b44c8833b5
commit 2a7e0b643e

View file

@ -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));