From e80fe743d291f8e0ff67867a117d0f7f95cf93b4 Mon Sep 17 00:00:00 2001 From: Jeffrey Snover Date: Thu, 23 Feb 2017 13:29:18 -0800 Subject: [PATCH] add a timeout to test-connection (#2492) --- .../commands/management/Computer.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs index 56379c2cbc..37ba3f4d78 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs @@ -127,6 +127,14 @@ namespace Microsoft.PowerShell.Commands [ValidateRange((int)0, (int)65500)] public Int32 BufferSize { get; set; } = 32; + /// + /// The following is the definition of the input parameter "TimeOut". + /// Time-out value in milliseconds. If a response is not received in this time, no response is assumed. The default is 1000 milliseconds. + /// + [Parameter] + [ValidateRange((int)1, Int32.MaxValue)] + public Int32 TimeOut { get; set; } = 1000; + /// /// The following is the definition of the input parameter "ComputerName". /// Value of the address requested. The form of the value can be either the @@ -399,6 +407,9 @@ namespace Microsoft.PowerShell.Commands FilterString.Append(" And "); FilterString.Append("BufferSize="); FilterString.Append(BufferSize); + FilterString.Append(" And "); + FilterString.Append("TimeOut="); + FilterString.Append(TimeOut); FilterString.Append(")"); return FilterString.ToString(); } @@ -612,6 +623,7 @@ namespace Microsoft.PowerShell.Commands using (CimSession cimSession = RemoteDiscoveryHelper.CreateCimSession(sourceComp, this.Credential, WsmanAuthentication, cancel.Token, this)) { + WriteVerbose(String.Format("WMI query {0} sent to {1}", querystring, sourceComp)); for (int echoRequestCount = 0; echoRequestCount < Count; echoRequestCount++) { IEnumerable mCollection = cimSession.QueryInstances(