From a47b77cc5c6d6062cd2f2b1a23681edf1905d31c Mon Sep 17 00:00:00 2001 From: Pat Hartl Date: Fri, 17 Nov 2023 21:39:01 -0600 Subject: [PATCH] Run scripts as admin if directed via script contents --- LANCommander.SDK/PowerShell/PowerShellScript.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/LANCommander.SDK/PowerShell/PowerShellScript.cs b/LANCommander.SDK/PowerShell/PowerShellScript.cs index 84a6d22..33b60ca 100644 --- a/LANCommander.SDK/PowerShell/PowerShellScript.cs +++ b/LANCommander.SDK/PowerShell/PowerShellScript.cs @@ -123,6 +123,9 @@ namespace LANCommander.SDK.PowerShell var wow64Value = IntPtr.Zero; + if (Contents.StartsWith("# Requires Admin")) + RunAsAdmin(); + foreach (var module in Modules) { scriptBuilder.AppendLine($"Import-Module \"{module}\"");