File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -351,17 +351,17 @@ private void InitializeRemoteSession()
351351
352352 _logger . LogInformation ( "Attempting to invoke PS-Session command on remote machine." ) ;
353353
354- var asyncResult = PS . BeginInvoke ( ) ;
355- if ( ! asyncResult . AsyncWaitHandle . WaitOne ( TimeSpan . FromSeconds ( timeoutSeconds ) ) )
356- {
357- PS . Stop ( ) ;
358- throw new TimeoutException (
359- $ "Could not establish a remote PowerShell session to '{ machineName } :{ port } ' within { timeoutSeconds } seconds. " +
360- "Verify WinRM is reachable and the firewall allows the connection." ) ;
361- }
362-
363354 try
364355 {
356+ var asyncResult = PS . BeginInvoke ( ) ;
357+ if ( ! asyncResult . AsyncWaitHandle . WaitOne ( TimeSpan . FromSeconds ( timeoutSeconds ) ) )
358+ {
359+ PS . Stop ( ) ;
360+ throw new TimeoutException (
361+ $ "Could not establish a remote PowerShell session to '{ machineName } :{ port } ' within { timeoutSeconds } seconds. " +
362+ "Verify WinRM is reachable and the firewall allows the connection." ) ;
363+ }
364+
365365 _PSSession = new Collection < PSObject > ( PS . EndInvoke ( asyncResult ) ) ;
366366 }
367367 catch ( Exception ex )
You can’t perform that action at this time.
0 commit comments