Skip to content

Commit

Permalink
Add an option to load the PowerShell profile
Browse files Browse the repository at this point in the history
  • Loading branch information
ofosos committed Feb 9, 2021
1 parent 28ad982 commit e15b326
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
public final class PowershellScript extends FileMonitoringTask {
private final String script;
private String powershellBinary = "powershell";
private boolean loadProfile = false;
private boolean capturingOutput;

@DataBoundConstructor public PowershellScript(String script) {
Expand All @@ -63,6 +64,11 @@ public void setPowershellBinary(String powershellBinary) {
this.powershellBinary = powershellBinary;
}

public boolean isLoadProfile() { return loadProfile; }

@DataBoundSetter
public void setLoadProfile(boolean loadProfile) { this.loadProfile = loadProfile; }

public String getScript() {
return script;
}
Expand Down Expand Up @@ -94,9 +100,12 @@ public String getScript() {

String powershellArgs;
if (launcher.isUnix()) {
powershellArgs = "-NoProfile -NonInteractive";
powershellArgs = "-NonInteractive";
} else {
powershellArgs = "-NoProfile -NonInteractive -ExecutionPolicy Bypass";
powershellArgs = "-NonInteractive -ExecutionPolicy Bypass";
}
if (!loadProfile) {
powershellArgs = "-NoProfile " + powershellArgs;
}
args.add(powershellBinary);
args.addAll(Arrays.asList(powershellArgs.split(" ")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@
<f:entry field="powershellBinary" title="Executable">
<f:select />
</f:entry>
<f:entry field="loadProfile" title="Load Profile">
<f:checkbox />
</f:entry>
</j:jelly>

0 comments on commit e15b326

Please sign in to comment.