public PowwaSession CreateSession(string sessionId, RunspaceConnectionInfo connectionInfo, ClientInfo clientInfo, string authenticatedUserName) { bool flag = false; PowwaSession powwaSession; PowwaSession stringSid = new PowwaSession(sessionId, authenticatedUserName, connectionInfo, clientInfo); string str = null; stringSid.AuthenticatedUserSid = PowwaAuthorizationManager.Instance.activeDirectoryHelper.ConvertAccountNameToStringSid(authenticatedUserName, out flag, out str); lock (this.sessionsLock) { bool userActiveSessions = this.GetUserActiveSessions(stringSid.AuthenticatedUserSid) < PowwaAuthorizationManager.Instance.UserSessionsLimit; if (userActiveSessions) { stringSid.Name = this.GetSessionName(stringSid); try { this.sessions.Add(sessionId, stringSid); } catch (ArgumentException argumentException) { PowwaEvents.PowwaEVENT_DEBUG_LOG0("CreateSession: Attempt to create a session that already exists"); throw new ArgumentException("There is already a PowWA session with the given ID", "sessionId"); } powwaSession = stringSid; } else { object[] objArray = new object[1]; objArray[0] = authenticatedUserName; throw new Exception(string.Format(CultureInfo.CurrentCulture, Resources.UserActiveSessionLimitReached, objArray)); } } return powwaSession; }
internal RemoteRunspace(TypeTable typeTable, RunspaceConnectionInfo connectionInfo, PSHost host, PSPrimitiveDictionary applicationArguments, string name = null, int id = -1) { this._runningPipelines = new ArrayList(); this._syncRoot = new object(); this._runspaceStateInfo = new System.Management.Automation.Runspaces.RunspaceStateInfo(RunspaceState.BeforeOpen); this._version = PSVersionInfo.PSVersion; this._runspaceEventQueue = new Queue<RunspaceEventQueueItem>(); this.id = -1; PSEtwLog.SetActivityIdForCurrentThread(base.InstanceId); this._applicationArguments = applicationArguments; PSEtwLog.LogOperationalVerbose(PSEventId.RunspaceConstructor, PSOpcode.Constructor, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, new object[] { base.InstanceId.ToString() }); if (connectionInfo is WSManConnectionInfo) { this._connectionInfo = ((WSManConnectionInfo) connectionInfo).Copy(); this._originalConnectionInfo = ((WSManConnectionInfo) connectionInfo).Copy(); } else if (connectionInfo is NewProcessConnectionInfo) { this._connectionInfo = ((NewProcessConnectionInfo) connectionInfo).Copy(); this._originalConnectionInfo = ((NewProcessConnectionInfo) connectionInfo).Copy(); } this._runspacePool = new System.Management.Automation.Runspaces.RunspacePool(1, 1, typeTable, host, applicationArguments, connectionInfo, name); this.Id = id; this.SetEventHandlers(); }
internal RemoteRunspacePoolInternal(Guid instanceId, string name, bool isDisconnected, ConnectCommandInfo[] connectCommands, RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable) : base(1, 1) { this.applicationPrivateDataReceived = new ManualResetEvent(false); this.friendlyName = string.Empty; if (connectCommands == null) { throw PSTraceSource.NewArgumentNullException("ConnectCommandInfo[]"); } if (connectionInfo == null) { throw PSTraceSource.NewArgumentNullException("WSManConnectionInfo"); } if (connectionInfo is WSManConnectionInfo) { this.connectionInfo = ((WSManConnectionInfo) connectionInfo).Copy(); } base.instanceId = instanceId; base.minPoolSz = -1; base.maxPoolSz = -1; PSEtwLog.LogOperationalVerbose(PSEventId.RunspacePoolConstructor, PSOpcode.Constructor, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, new object[] { instanceId.ToString(), this.minPoolSz.ToString(CultureInfo.InvariantCulture), this.maxPoolSz.ToString(CultureInfo.InvariantCulture) }); this.connectCommands = connectCommands; this.Name = name; base.host = host; this.dispatchTable = new DispatchTable<object>(); this.SetRunspacePoolState(new RunspacePoolStateInfo(RunspacePoolState.Disconnected, null)); this.CreateDSHandler(typeTable); this.availableForConnection = isDisconnected; }
internal RemoteRunspacePoolInternal(int minRunspaces, int maxRunspaces, TypeTable typeTable, PSHost host, PSPrimitiveDictionary applicationArguments, RunspaceConnectionInfo connectionInfo, string name = null) : base(minRunspaces, maxRunspaces) { this.applicationPrivateDataReceived = new ManualResetEvent(false); this.friendlyName = string.Empty; if (connectionInfo == null) { throw PSTraceSource.NewArgumentNullException("WSManConnectionInfo"); } PSEtwLog.LogOperationalVerbose(PSEventId.RunspacePoolConstructor, PSOpcode.Constructor, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, new object[] { this.instanceId.ToString(), this.minPoolSz.ToString(CultureInfo.InvariantCulture), this.maxPoolSz.ToString(CultureInfo.InvariantCulture) }); if (connectionInfo is WSManConnectionInfo) { this.connectionInfo = ((WSManConnectionInfo) connectionInfo).Copy(); } else if (connectionInfo is NewProcessConnectionInfo) { this.connectionInfo = ((NewProcessConnectionInfo) connectionInfo).Copy(); } base.host = host; this.applicationArguments = applicationArguments; this.availableForConnection = false; this.dispatchTable = new DispatchTable<object>(); if (!string.IsNullOrEmpty(name)) { this.Name = name; } this.CreateDSHandler(typeTable); }
internal ClientRemoteSessionDSHandlerImpl(ClientRemoteSession session, PSRemotingCryptoHelper cryptoHelper, RunspaceConnectionInfo connectionInfo, ClientRemoteSession.URIDirectionReported uriRedirectionHandler) { if (session == null) { throw PSTraceSource.NewArgumentNullException("session"); } this._session = session; this._stateMachine = new ClientRemoteSessionDSHandlerStateMachine(); this._stateMachine.StateChanged += new EventHandler<RemoteSessionStateEventArgs>(this.HandleStateChanged); this._connectionInfo = connectionInfo; this._cryptoHelper = cryptoHelper; if (this._connectionInfo is NewProcessConnectionInfo) { this._transportManager = new OutOfProcessClientSessionTransportManager(this._session.RemoteRunspacePoolInternal.InstanceId, (NewProcessConnectionInfo) this._connectionInfo, cryptoHelper); } else { this._transportManager = new WSManClientSessionTransportManager(this._session.RemoteRunspacePoolInternal.InstanceId, (WSManConnectionInfo) this._connectionInfo, cryptoHelper, this._session.RemoteRunspacePoolInternal.Name); } this._transportManager.DataReceived += new EventHandler<RemoteDataEventArgs>(this.DispatchInputQueueData); this._transportManager.WSManTransportErrorOccured += new EventHandler<TransportErrorOccuredEventArgs>(this.HandleTransportError); this._transportManager.CloseCompleted += new EventHandler<EventArgs>(this.HandleCloseComplete); this._transportManager.DisconnectCompleted += new EventHandler<EventArgs>(this.HandleDisconnectComplete); this._transportManager.ReconnectCompleted += new EventHandler<EventArgs>(this.HandleReconnectComplete); this._transportManager.RobustConnectionNotification += new EventHandler<ConnectionStatusEventArgs>(this.HandleRobustConnectionNotification); WSManConnectionInfo info = connectionInfo as WSManConnectionInfo; if (info != null) { this.uriRedirectionHandler = uriRedirectionHandler; this.maxUriRedirectionCount = info.MaximumConnectionRedirectionCount; } }
/// <summary> /// Creates an instance of ClientRemoteSessionDSHandlerImpl /// </summary> internal ClientRemoteSessionDSHandlerImpl(ClientRemoteSession session, PSRemotingCryptoHelper cryptoHelper, RunspaceConnectionInfo connectionInfo, ClientRemoteSession.URIDirectionReported uriRedirectionHandler) { Dbg.Assert(_maxUriRedirectionCount >= 0, "maxUriRedirectionCount cannot be less than 0."); if (session == null) { throw PSTraceSource.NewArgumentNullException("session"); } _session = session; //Create state machine _stateMachine = new ClientRemoteSessionDSHandlerStateMachine(); _stateMachine.StateChanged += HandleStateChanged; _connectionInfo = connectionInfo; // Create transport manager _cryptoHelper = cryptoHelper; _transportManager = _connectionInfo.CreateClientSessionTransportManager( _session.RemoteRunspacePoolInternal.InstanceId, _session.RemoteRunspacePoolInternal.Name, cryptoHelper); _transportManager.DataReceived += DispatchInputQueueData; _transportManager.WSManTransportErrorOccured += HandleTransportError; _transportManager.CloseCompleted += HandleCloseComplete; _transportManager.DisconnectCompleted += HandleDisconnectComplete; _transportManager.ReconnectCompleted += HandleReconnectComplete; _transportManager.RobustConnectionNotification += new EventHandler<ConnectionStatusEventArgs>(HandleRobustConnectionNotification); WSManConnectionInfo wsmanConnectionInfo = _connectionInfo as WSManConnectionInfo; if (null != wsmanConnectionInfo) { // only WSMan transport supports redirection // store the uri redirection handler and authmechanism // for uri redirection. _uriRedirectionHandler = uriRedirectionHandler; _maxUriRedirectionCount = wsmanConnectionInfo.MaximumConnectionRedirectionCount; } }
/// <summary> /// Construct a runspace pool object. /// </summary> /// <param name="minRunspaces">Min runspaces.</param> /// <param name="maxRunspaces">Max runspaces.</param> /// <param name="typeTable">TypeTable.</param> /// <param name="host">Host.</param> /// <param name="applicationArguments">App arguments.</param> /// <param name="connectionInfo">Connection information.</param> /// <param name="name">Session name.</param> internal RunspacePool( int minRunspaces, int maxRunspaces, TypeTable typeTable, PSHost host, PSPrimitiveDictionary applicationArguments, RunspaceConnectionInfo connectionInfo, string name = null) { _internalPool = new RemoteRunspacePoolInternal( minRunspaces, maxRunspaces, typeTable, host, applicationArguments, connectionInfo, name); IsRemote = true; }
/// <summary> /// Creates a runspace pool object in a disconnected state that is /// ready to connect to a remote runspace pool session specified by /// the instanceId parameter. /// </summary> /// <param name="isDisconnected">Indicates whether the shell/runspace pool is disconnected.</param> /// <param name="instanceId">Identifies a remote runspace pool session to connect to.</param> /// <param name="name">Friendly name for runspace pool.</param> /// <param name="connectCommands">Runspace pool running commands information.</param> /// <param name="connectionInfo">Connection information of remote server.</param> /// <param name="host">PSHost object.</param> /// <param name="typeTable">TypeTable used for serialization/deserialization of remote objects.</param> internal RunspacePool( bool isDisconnected, Guid instanceId, string name, ConnectCommandInfo[] connectCommands, RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable) { // Disconnect-Connect semantics are currently only supported in WSMan transport. if (!(connectionInfo is WSManConnectionInfo)) { throw new NotSupportedException(); } _internalPool = new RemoteRunspacePoolInternal(instanceId, name, isDisconnected, connectCommands, connectionInfo, host, typeTable); IsRemote = true; }
internal RemoteRunspace(System.Management.Automation.Runspaces.RunspacePool runspacePool) { this._runningPipelines = new ArrayList(); this._syncRoot = new object(); this._runspaceStateInfo = new System.Management.Automation.Runspaces.RunspaceStateInfo(RunspaceState.BeforeOpen); this._version = PSVersionInfo.PSVersion; this._runspaceEventQueue = new Queue<RunspaceEventQueueItem>(); this.id = -1; if ((runspacePool.RunspacePoolStateInfo.State != RunspacePoolState.Disconnected) || !(runspacePool.ConnectionInfo is WSManConnectionInfo)) { throw PSTraceSource.NewInvalidOperationException("RunspaceStrings", "InvalidRunspacePool", new object[0]); } this._runspacePool = runspacePool; this._runspacePool.RemoteRunspacePoolInternal.SetMinRunspaces(1); this._runspacePool.RemoteRunspacePoolInternal.SetMaxRunspaces(1); this._connectionInfo = ((WSManConnectionInfo) runspacePool.ConnectionInfo).Copy(); this.SetRunspaceState(RunspaceState.Disconnected, null); this._runspaceAvailability = this._runspacePool.RemoteRunspacePoolInternal.AvailableForConnection ? System.Management.Automation.Runspaces.RunspaceAvailability.None : System.Management.Automation.Runspaces.RunspaceAvailability.Busy; this.SetEventHandlers(); PSEtwLog.SetActivityIdForCurrentThread(base.InstanceId); PSEtwLog.LogOperationalVerbose(PSEventId.RunspaceConstructor, PSOpcode.Constructor, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, new object[] { base.InstanceId.ToString() }); }
internal RunspacePool( int minRunspaces, int maxRunspaces, TypeTable typeTable, PSHost host, PSPrimitiveDictionary applicationArguments, RunspaceConnectionInfo connectionInfo) { using (RunspacePool.tracer.TraceConstructor((object)this)) { switch (connectionInfo) { case WSManConnectionInfo _: case NewProcessConnectionInfo _: this.internalPool = (RunspacePoolInternal) new RemoteRunspacePoolInternal(minRunspaces, maxRunspaces, typeTable, host, applicationArguments, connectionInfo); this.isRemote = true; break; default: throw new NotSupportedException(); } } }
/// <summary> /// Queries the server for disconnected runspace pools and creates an array of runspace /// pool objects associated with each disconnected runspace pool on the server. Each /// runspace pool object in the returned array is in the Disconnected state and can be /// connected to the server by calling the Connect() method on the runspace pool. /// </summary> /// <param name="connectionInfo">Connection object for the target server.</param> /// <returns>Array of RunspacePool objects each in the Disconnected state.</returns> public static RunspacePool[] GetRunspacePools(RunspaceConnectionInfo connectionInfo) { return(GetRunspacePools(connectionInfo, null, null)); }
/// <summary> /// /// </summary> /// <param name="typeTable"> /// The TypeTable to use while deserializing/serializing remote objects. /// TypeTable has the following information used by serializer: /// 1. SerializationMethod /// 2. SerializationDepth /// 3. SpecificSerializationProperties /// TypeTable has the following information used by deserializer: /// 1. TargetTypeForDeserialization /// 2. TypeConverter /// </param> /// <param name="host"></param> /// <param name="connectionInfo"></param> /// <returns></returns> public static Runspace CreateRunspace(RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable) { return CreateRunspace(connectionInfo, host, typeTable, null, null); }
internal RunspacePool(bool isDisconnected, Guid instanceId, string name, ConnectCommandInfo[] connectCommands, RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable) { this.syncObject = new object(); if (!(connectionInfo is WSManConnectionInfo)) { throw new NotSupportedException(); } this.internalPool = new System.Management.Automation.Runspaces.Internal.RemoteRunspacePoolInternal(instanceId, name, isDisconnected, connectCommands, connectionInfo, host, typeTable); this.isRemote = true; }
public static Runspace CreateRunspace(RunspaceConnectionInfo connectionInfo) => RunspaceFactory.CreateRunspace((PSHost)null, connectionInfo);
public static RunspacePool CreateRunspacePool(int minRunspaces, int maxRunspaces, RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable) { return CreateRunspacePool(minRunspaces, maxRunspaces, connectionInfo, host, typeTable, null); }
public static Runspace[] GetRunspaces(RunspaceConnectionInfo connectionInfo, PSHost host) { return GetRunspaces(connectionInfo, host, null); }
public static RunspacePool CreateRunspacePool(int minRunspaces, int maxRunspaces, RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable, PSPrimitiveDictionary applicationArguments) { if (!(connectionInfo is WSManConnectionInfo) && !(connectionInfo is NewProcessConnectionInfo)) { throw new NotSupportedException(); } if (connectionInfo is WSManConnectionInfo) { RemotingCommandUtil.CheckHostRemotingPrerequisites(); } return(new RunspacePool(minRunspaces, maxRunspaces, typeTable, host, applicationArguments, connectionInfo, null)); }
internal CreateCompleteEventArgs(RunspaceConnectionInfo connectionInfo) { this._connectionInfo = connectionInfo; }
public static Runspace[] GetRunspaces(RunspaceConnectionInfo connectionInfo) { return GetRunspaces(connectionInfo, null, null); }
public static RunspacePool[] GetRunspacePools(RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable) { return System.Management.Automation.Runspaces.Internal.RemoteRunspacePoolInternal.GetRemoteRunspacePools(connectionInfo, host, typeTable); }
internal RunspacePool(int minRunspaces, int maxRunspaces, TypeTable typeTable, PSHost host, PSPrimitiveDictionary applicationArguments, RunspaceConnectionInfo connectionInfo, string name = null) { this.syncObject = new object(); if (!(connectionInfo is WSManConnectionInfo) && !(connectionInfo is NewProcessConnectionInfo)) { throw new NotSupportedException(); } this.internalPool = new System.Management.Automation.Runspaces.Internal.RemoteRunspacePoolInternal(minRunspaces, maxRunspaces, typeTable, host, applicationArguments, connectionInfo, name); this.isRemote = true; }
/// <summary> /// Queries the server for disconnected runspace pools and creates an array of runspace /// pool objects associated with each disconnected runspace pool on the server. Each /// runspace pool object in the returned array is in the Disconnected state and can be /// connected to the server by calling the Connect() method on the runspace pool. /// </summary> /// <param name="connectionInfo">Connection object for the target server.</param> /// <param name="host">Client host object.</param> /// <param name="typeTable">TypeTable object.</param> /// <returns>Array of RunspacePool objects each in the Disconnected state.</returns> public static RunspacePool[] GetRunspacePools(RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable) { return(RemoteRunspacePoolInternal.GetRemoteRunspacePools(connectionInfo, host, typeTable)); }
public static Runspace[] GetRunspaces(RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable) { return RemoteRunspace.GetRemoteRunspaces(connectionInfo, host, typeTable); }
/// <summary> /// Returns a single disconnected Runspace object targeted to the remote computer and remote /// session as specified by the connection, session Id, and command Id parameters. /// </summary> /// <param name="connectionInfo">Connection object for the target server.</param> /// <param name="sessionId">Id of a disconnected remote session on the target server.</param> /// <param name="commandId">Optional Id of a disconnected command running in the disconnected remote session on the target server.</param> /// <param name="host">Optional client host object.</param> /// <param name="typeTable">Optional TypeTable object.</param> /// <returns>Disconnected runspace corresponding to the provided session Id.</returns> public static Runspace GetRunspace(RunspaceConnectionInfo connectionInfo, Guid sessionId, Guid? commandId, PSHost host, TypeTable typeTable) { return RemoteRunspace.GetRemoteRunspace(connectionInfo, sessionId, commandId, host, typeTable); }
public static Runspace CreateRunspace( PSHost host, RunspaceConnectionInfo connectionInfo) { return(RunspaceFactory.CreateRunspace(connectionInfo, host, (TypeTable)null)); }
/// <summary> /// Create temporary remote runspace. /// </summary> private RemoteRunspace CreateTemporaryRemoteRunspaceForPowerShellDirect(PSHost host, RunspaceConnectionInfo connectionInfo) { // Create and open the runspace. TypeTable typeTable = TypeTable.LoadDefaultTypeFiles(); RemoteRunspace remoteRunspace = RunspaceFactory.CreateRunspace(connectionInfo, host, typeTable) as RemoteRunspace; remoteRunspace.Name = "PowerShellDirectAttach"; Dbg.Assert(remoteRunspace != null, "Expected remoteRunspace != null"); try { remoteRunspace.Open(); // Mark this temporary runspace so that it closes on pop. remoteRunspace.ShouldCloseOnPop = true; } finally { // Make sure we dispose the temporary runspace if something bad happens. if (remoteRunspace.RunspaceStateInfo.State != RunspaceState.Opened) { remoteRunspace.Dispose(); remoteRunspace = null; } } return remoteRunspace; }
public static RunspacePool CreateRunspacePool(int minRunspaces, int maxRunspaces, RunspaceConnectionInfo connectionInfo) { return CreateRunspacePool(minRunspaces, maxRunspaces, connectionInfo, null); }
/// <summary> /// /// </summary> /// <param name="connectionInfo"></param> /// <param name="host"></param> /// <param name="typeTable"> /// The TypeTable to use while deserializing/serializing remote objects. /// TypeTable has the following information used by serializer: /// 1. SerializationMethod /// 2. SerializationDepth /// 3. SpecificSerializationProperties /// TypeTable has the following information used by deserializer: /// 1. TargetTypeForDeserialization /// 2. TypeConverter /// </param> /// <param name="applicationArguments"> /// Application arguments the server can see in <see cref="System.Management.Automation.Remoting.PSSenderInfo.ApplicationArguments"/> /// </param> /// <param name="name">Name for remote runspace.</param> /// <returns></returns> public static Runspace CreateRunspace(RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable, PSPrimitiveDictionary applicationArguments, string name) { if ((!(connectionInfo is WSManConnectionInfo)) && (!(connectionInfo is NewProcessConnectionInfo)) && (!(connectionInfo is NamedPipeConnectionInfo)) && (!(connectionInfo is SSHConnectionInfo)) && (!(connectionInfo is VMConnectionInfo)) && (!(connectionInfo is ContainerConnectionInfo))) { throw new NotSupportedException(); } if (connectionInfo is WSManConnectionInfo) { RemotingCommandUtil.CheckHostRemotingPrerequisites(); } return new RemoteRunspace(typeTable, connectionInfo, host, applicationArguments, name); }
public static RunspacePool CreateRunspacePool(int minRunspaces, int maxRunspaces, RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable, PSPrimitiveDictionary applicationArguments) { if ((!(connectionInfo is WSManConnectionInfo)) && (!(connectionInfo is NewProcessConnectionInfo)) && (!(connectionInfo is NamedPipeConnectionInfo)) && (!(connectionInfo is VMConnectionInfo)) && (!(connectionInfo is ContainerConnectionInfo))) { throw new NotSupportedException(); } if (connectionInfo is WSManConnectionInfo) { RemotingCommandUtil.CheckHostRemotingPrerequisites(); } return new RunspacePool(minRunspaces, maxRunspaces, typeTable, host, applicationArguments, connectionInfo); }
/// <summary> /// /// </summary> /// <param name="connectionInfo"></param> /// <returns></returns> public static Runspace CreateRunspace(RunspaceConnectionInfo connectionInfo) { return CreateRunspace(null, connectionInfo); }
/// <summary> /// /// </summary> /// <param name="typeTable"> /// The TypeTable to use while deserializing/serializing remote objects. /// TypeTable has the following information used by serializer: /// 1. SerializationMethod /// 2. SerializationDepth /// 3. SpecificSerializationProperties /// TypeTable has the following information used by deserializer: /// 1. TargetTypeForDeserialization /// 2. TypeConverter /// </param> /// <param name="host"></param> /// <param name="connectionInfo"></param> /// <param name="applicationArguments"> /// Application arguments the server can see in <see cref="System.Management.Automation.Remoting.PSSenderInfo.ApplicationArguments"/> /// </param> /// <returns></returns> public static Runspace CreateRunspace(RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable, PSPrimitiveDictionary applicationArguments) { return CreateRunspace(connectionInfo, host, typeTable, applicationArguments, null); }
internal RunspacePool(int minRunspaces, int maxRunspaces, TypeTable typeTable, PSHost host, PSPrimitiveDictionary applicationArguments, RunspaceConnectionInfo connectionInfo) { throw new NotImplementedException(); }
/// <summary> /// /// </summary> /// <param name="host"></param> /// <param name="connectionInfo"></param> /// <returns></returns> public static Runspace CreateRunspace(PSHost host, RunspaceConnectionInfo connectionInfo) { return CreateRunspace(connectionInfo, host, null); }
public static Runspace CreateRunspace(RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable, PSPrimitiveDictionary applicationArguments) { if (!(connectionInfo is WSManConnectionInfo) && !(connectionInfo is NewProcessConnectionInfo)) { throw new NotSupportedException(); } if (connectionInfo is WSManConnectionInfo) { RemotingCommandUtil.CheckHostRemotingPrerequisites(); } return new RemoteRunspace(typeTable, connectionInfo, host, applicationArguments, null, -1); }
internal static RunspacePool[] GetRemoteRunspacePools(RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable) { WSManConnectionInfo wsmanConnectionInfo = connectionInfo as WSManConnectionInfo; if (wsmanConnectionInfo == null) { throw new NotSupportedException(); } List<RunspacePool> list = new List<RunspacePool>(); foreach (PSObject obj2 in RemoteRunspacePoolEnumeration.GetRemotePools(wsmanConnectionInfo)) { WSManConnectionInfo info2 = wsmanConnectionInfo.Copy(); PSPropertyInfo info3 = obj2.Properties["ShellId"]; PSPropertyInfo info4 = obj2.Properties["State"]; PSPropertyInfo info5 = obj2.Properties["Name"]; PSPropertyInfo info6 = obj2.Properties["ResourceUri"]; if (((info3 != null) && (info4 != null)) && ((info5 != null) && (info6 != null))) { string name = info5.Value.ToString(); string str2 = info6.Value.ToString(); bool isDisconnected = info4.Value.ToString().Equals("Disconnected", StringComparison.OrdinalIgnoreCase); Guid shellId = Guid.Parse(info3.Value.ToString()); if (str2.StartsWith("http://schemas.microsoft.com/powershell/", StringComparison.OrdinalIgnoreCase)) { Collection<PSObject> remoteCommands; UpdateWSManConnectionInfo(info2, obj2); info2.EnableNetworkAccess = true; List<ConnectCommandInfo> list2 = new List<ConnectCommandInfo>(); try { remoteCommands = RemoteRunspacePoolEnumeration.GetRemoteCommands(shellId, info2); } catch (CmdletInvocationException exception) { if ((exception.InnerException == null) || !(exception.InnerException is InvalidOperationException)) { throw; } continue; } foreach (PSObject obj3 in remoteCommands) { PSPropertyInfo info7 = obj3.Properties["CommandId"]; PSPropertyInfo info8 = obj3.Properties["CommandLine"]; if (info7 != null) { string cmdStr = (info8 != null) ? info8.Value.ToString() : string.Empty; Guid cmdId = Guid.Parse(info7.Value.ToString()); list2.Add(new ConnectCommandInfo(cmdId, cmdStr)); } } RunspacePool item = new RunspacePool(isDisconnected, shellId, name, list2.ToArray(), info2, host, typeTable); list.Add(item); } } } return list.ToArray(); }
public static RunspacePool CreateRunspacePool(int minRunspaces, int maxRunspaces, RunspaceConnectionInfo connectionInfo) { return(CreateRunspacePool(minRunspaces, maxRunspaces, connectionInfo, null)); }
public static Runspace[] GetRunspaces(RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable) { return(RemoteRunspace.GetRemoteRunspaces(connectionInfo, host, typeTable)); }
/// <summary> /// </summary> /// <param name="typeTable"> /// The TypeTable to use while deserializing/serializing remote objects. /// TypeTable has the following information used by serializer: /// 1. SerializationMethod /// 2. SerializationDepth /// 3. SpecificSerializationProperties /// TypeTable has the following information used by deserializer: /// 1. TargetTypeForDeserialization /// 2. TypeConverter /// </param> /// <param name="host"></param> /// <param name="connectionInfo"></param> /// <returns></returns> public static Runspace CreateRunspace(RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable) { return(CreateRunspace(connectionInfo, host, typeTable, null, null)); }
/// <summary> /// Queries the server for disconnected runspace pools and creates an array of runspace /// pool objects associated with each disconnected runspace pool on the server. Each /// runspace pool object in the returned array is in the Disconnected state and can be /// connected to the server by calling the Connect() method on the runspace pool. /// </summary> /// <param name="connectionInfo">Connection object for the target server.</param> /// <param name="host">Client host object.</param> /// <returns>Array of RunspacePool objects each in the Disconnected state.</returns> public static RunspacePool[] GetRunspacePools(RunspaceConnectionInfo connectionInfo, PSHost host) { return(GetRunspacePools(connectionInfo, host, null)); }
/// <summary> /// </summary> /// <param name="host"></param> /// <param name="connectionInfo"></param> /// <returns></returns> public static Runspace CreateRunspace(PSHost host, RunspaceConnectionInfo connectionInfo) { return(CreateRunspace(connectionInfo, host, null)); }
/// <summary> /// Queries the server for disconnected runspace pools and creates an array of runspace /// pool objects associated with each disconnected runspace pool on the server. Each /// runspace pool object in the returned array is in the Disconnected state and can be /// connected to the server by calling the Connect() method on the runspace pool. /// </summary> /// <param name="connectionInfo">Connection object for the target server.</param> /// <param name="host">Client host object.</param> /// <param name="typeTable">TypeTable object.</param> /// <returns>Array of RunspacePool objects each in the Disconnected state.</returns> public static RunspacePool[] GetRunspacePools(RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable) { return RemoteRunspacePoolInternal.GetRemoteRunspacePools(connectionInfo, host, typeTable); }
public static RunspacePool[] GetRunspacePools(RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable) { return(System.Management.Automation.Runspaces.Internal.RemoteRunspacePoolInternal.GetRemoteRunspacePools(connectionInfo, host, typeTable)); }
public static RunspacePool CreateRunspacePool(int minRunspaces, int maxRunspaces, RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable) { return(CreateRunspacePool(minRunspaces, maxRunspaces, connectionInfo, host, typeTable, null)); }
internal NamedPipeClientSessionTransportManagerBase( RunspaceConnectionInfo connectionInfo, Guid runspaceId, PSRemotingCryptoHelper cryptoHelper, string threadName) : base(runspaceId, cryptoHelper) { if (connectionInfo == null) { throw new PSArgumentNullException("connectionInfo"); } _connectionInfo = connectionInfo; _threadName = threadName; Fragmentor.FragmentSize = RemoteSessionNamedPipeServer.NamedPipeBufferSizeForRemoting; }
/// <summary> /// </summary> /// <param name="typeTable"> /// The TypeTable to use while deserializing/serializing remote objects. /// TypeTable has the following information used by serializer: /// 1. SerializationMethod /// 2. SerializationDepth /// 3. SpecificSerializationProperties /// TypeTable has the following information used by deserializer: /// 1. TargetTypeForDeserialization /// 2. TypeConverter /// </param> /// <param name="host"></param> /// <param name="connectionInfo"></param> /// <param name="applicationArguments"> /// Application arguments the server can see in <see cref="System.Management.Automation.Remoting.PSSenderInfo.ApplicationArguments"/> /// </param> /// <returns></returns> public static Runspace CreateRunspace(RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable, PSPrimitiveDictionary applicationArguments) { return(CreateRunspace(connectionInfo, host, typeTable, applicationArguments, null)); }
/// <summary> /// Create a transport manager for command /// </summary> /// <param name="connectionInfo"></param> /// <param name="cmd"></param> /// <param name="noInput"></param> /// <returns></returns> internal override BaseClientCommandTransportManager CreateClientCommandTransportManager( RunspaceConnectionInfo connectionInfo, ClientRemotePowerShell cmd, bool noInput) { Dbg.Assert(null != cmd, "Cmd cannot be null"); OutOfProcessClientCommandTransportManager result = new OutOfProcessClientCommandTransportManager(cmd, noInput, this, stdInWriter); AddCommandTransportManager(cmd.InstanceId, result); return result; }
/// <summary> /// </summary> /// <param name="connectionInfo"></param> /// <returns></returns> public static Runspace CreateRunspace(RunspaceConnectionInfo connectionInfo) { return(CreateRunspace(null, connectionInfo)); }