Skip to content

Commit

Permalink
Merge pull request #504 from mkht/issue503
Browse files Browse the repository at this point in the history
Improve VerbosePreference and Verbose switch behavior.
  • Loading branch information
darkoperator authored Jun 5, 2024
2 parents 1c745f4 + 51f13d6 commit ba95131
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions Source/PoshSSH/PoshSSH/NewSessionBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,24 @@ protected override void BeginProcessing()
}
protected BaseClient CreateConnection(string computer)
{
var isVerboseEnabled = MyInvocation.BoundParameters.ContainsKey("Verbose") ||
(ActionPreference)this.SessionState.PSVariable.GetValue("VerbosePreference") != ActionPreference.SilentlyContinue;
var isVerboseEnabled = MyInvocation.BoundParameters.ContainsKey("Verbose");
if (!isVerboseEnabled)
{
switch (this.SessionState.PSVariable.GetValue("VerbosePreference"))
{
case ActionPreference apVp:
isVerboseEnabled = (apVp != ActionPreference.SilentlyContinue);
break;

case string strVp:
isVerboseEnabled = Enum.TryParse<ActionPreference>(strVp, true, out ActionPreference vp) &&
(vp != ActionPreference.SilentlyContinue);
break;

default:
break;
}
}

ConnectionInfo connectInfo = null;
switch (ParameterSetName)
Expand Down

0 comments on commit ba95131

Please sign in to comment.