Beispiel #1
0
        internal void OpenAsync()
        {
            // Always create runspace with WSManConnectionInfo.EnableNetworkAccess set to true.
            WSManConnectionInfo copyConnectionInfo = ConnectionInfo.Copy();
            copyConnectionInfo.EnableNetworkAccess = true;

            // If the remote runspace is not available after crash/shutdown, 
            // activity task resume will fall back to reexecuting in a new runspace is assigned for the connection
            if (!CheckAndReconnectAfterCrashOrShutdown(copyConnectionInfo))
            {
                _runspace = RunspaceFactory.CreateRunspace(copyConnectionInfo, null, LocalRunspaceProvider.SharedTypeTable);
                _runspace.StateChanged += RunspaceStateChanged;
                _tracer.WriteMessage("PSW Conn: Calling OpenAsync on runspace");
                _runspace.OpenAsync();
            }
        }
Beispiel #2
0
 public void PushRunspace(Runspace runspace)
 {
     Runspaces.Push(runspace);
     if (runspace.RunspaceAvailability != RunspaceAvailability.Available) runspace.OpenAsync();
 }
Beispiel #3
0
 public virtual void OpenAsync()
 {
     runspace.OpenAsync();
 }
 public DynamicPowershell() {
     _runspace = RunspaceFactory.CreateRunspace();
     if(_runspace.RunspaceStateInfo.State == RunspaceState.BeforeOpen) {
         _runspace.OpenAsync();
     }
     _runspaceIsOwned = true;
 }