Skip to content

Commit

Permalink
Change PowerShell ExecutionPolicy to RemoteSigned (#4071)
Browse files Browse the repository at this point in the history
Change PowerShell ExecutionPolicy to RemoteSigned when executing embedded scripts.
  • Loading branch information
LiliaSabitova committed Dec 1, 2022
1 parent 550a7d4 commit 0be1c41
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Agent.Worker/DiagnosticLogManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ private async Task<string> GetLocalGroupMembership()

string scriptFile = Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Bin), "powershell", "Get-LocalGroupMembership.ps1").Replace("'", "''");
ArgUtil.File(scriptFile, nameof(scriptFile));
string arguments = $@"-NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "". '{scriptFile}'""";
string arguments = $@"-NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy RemoteSigned -Command "". '{scriptFile}'""";

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public async Task<List<Capability>> GetCapabilitiesAsync(AgentSettings settings,
string powerShellExe = HostContext.GetService<IPowerShellExeUtil>().GetPath();
string scriptFile = Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Bin), "powershell", "Add-Capabilities.ps1").Replace("'", "''");
ArgUtil.File(scriptFile, nameof(scriptFile));
string arguments = $@"-NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "". '{scriptFile}'""";
string arguments = $@"-NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy RemoteSigned -Command "". '{scriptFile}'""";

string enablePrereleaseVSVersions = AgentKnobs.EnableVSPreReleaseVersions.GetValue(UtilKnobValueContext.Instance()).AsString();
Environment.SetEnvironmentVariable("IncludePrereleaseVersions", enablePrereleaseVSVersions);
Expand Down

0 comments on commit 0be1c41

Please sign in to comment.