From 0bf4e8cc6d8c8e98b7c2ff59779e98e30066a159 Mon Sep 17 00:00:00 2001 From: Pat Hartl Date: Wed, 13 Dec 2023 23:38:13 -0600 Subject: [PATCH] Import PowerShell cmdlets module based on SDK assembly's location Fixes #45 --- LANCommander.SDK/PowerShell/PowerShellScript.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LANCommander.SDK/PowerShell/PowerShellScript.cs b/LANCommander.SDK/PowerShell/PowerShellScript.cs index a9ca1915..13bee986 100644 --- a/LANCommander.SDK/PowerShell/PowerShellScript.cs +++ b/LANCommander.SDK/PowerShell/PowerShellScript.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; +using System.Reflection; using System.Runtime.InteropServices; using System.Text; @@ -33,7 +34,7 @@ namespace LANCommander.SDK.PowerShell AddArgument("ExecutionPolicy", "Unrestricted"); - var moduleManifests = Directory.EnumerateFiles(Environment.CurrentDirectory, "LANCommander.PowerShell.psd1", SearchOption.AllDirectories); + var moduleManifests = Directory.EnumerateFiles(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "LANCommander.PowerShell.psd1", SearchOption.AllDirectories); if (moduleManifests.Any()) AddModule(moduleManifests.First());