From 3e90c0abd115c0584ef6dd6cb971bfe666d89368 Mon Sep 17 00:00:00 2001 From: Sander Declerck Date: Thu, 5 Feb 2026 10:12:43 +0100 Subject: [PATCH] Import module for execution policy --- .../safe-chain/src/shell-integration/helpers.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/safe-chain/src/shell-integration/helpers.js b/packages/safe-chain/src/shell-integration/helpers.js index 3c60ac1..d243123 100644 --- a/packages/safe-chain/src/shell-integration/helpers.js +++ b/packages/safe-chain/src/shell-integration/helpers.js @@ -258,11 +258,15 @@ export function validatePowerShellExecutionPolicy(shellExecutableName) { try { // Security: Use literal command string, no interpolation - const policy = execSync('-Command "Get-ExecutionPolicy"', { - encoding: "utf8", - shell: shellExecutableName, - timeout: 5000, // 5 second timeout - }).trim(); + // Import the Security module first - works for both powershell.exe and pwsh.exe + const policy = execSync( + "Import-Module Microsoft.PowerShell.Security; Get-ExecutionPolicy", + { + encoding: "utf8", + shell: shellExecutableName, + timeout: 5000, // 5 second timeout + } + ).trim(); const acceptablePolicies = ["RemoteSigned", "Unrestricted", "Bypass"]; return {