From 734cd48f9bdb9fc62848450667bf7480dfb5bd9c Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Wed, 7 Aug 2024 23:18:44 +0200 Subject: [PATCH] Fix profile script for individual profiles --- scripts/Common/Software/PowerShell/Profile.ps1 | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/Common/Software/PowerShell/Profile.ps1 b/scripts/Common/Software/PowerShell/Profile.ps1 index 1376be54..833ce2ed 100644 --- a/scripts/Common/Software/PowerShell/Profile.ps1 +++ b/scripts/Common/Software/PowerShell/Profile.ps1 @@ -83,7 +83,7 @@ $null = New-Module { } if ($Category) { - $profiles = $profiles | ForEach-Object { Join-Path (Split-Path -Parent $_) "conf.d" "$Category.ps1" }; + $profiles = @($profiles | ForEach-Object { Join-Path (Split-Path -Parent $_) "conf.d" "$Category.ps1" }); } $profiles | ForEach-Object { @@ -102,4 +102,20 @@ $null = New-Module { -Script $Script; }; } + + <# + .SYNOPSIS + Creates an eval-script using the `[scriptblock]::Create` method. + + .PARAMETER Initializer + The code to evaluate. + #> + function Get-ScriptInitializer { + param ( + [Parameter(Position=0, Mandatory=$true)] + $Initializer + ) + + return ". ([scriptblock]::Create(($Initializer) -join `"``n`"))"; + } };