diff --git a/Source/PoshSSH/PoshSSH/NewSessionBase.cs b/Source/PoshSSH/PoshSSH/NewSessionBase.cs index 5e69f70..0f725bc 100644 --- a/Source/PoshSSH/PoshSSH/NewSessionBase.cs +++ b/Source/PoshSSH/PoshSSH/NewSessionBase.cs @@ -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(strVp, true, out ActionPreference vp) && + (vp != ActionPreference.SilentlyContinue); + break; + + default: + break; + } + } ConnectionInfo connectInfo = null; switch (ParameterSetName)