protected RunspaceBase(PSHost host, System.Management.Automation.Runspaces.InitialSessionState initialSessionState, bool suppressClone) { this._version = PSVersionInfo.PSVersion; this._runspaceStateInfo = new System.Management.Automation.Runspaces.RunspaceStateInfo(System.Management.Automation.Runspaces.RunspaceState.BeforeOpen); this._syncRoot = new object(); this._runspaceEventQueue = new Queue <RunspaceEventQueueItem> (); this.RunspaceOpening = new ManualResetEventSlim(false); this._runningPipelines = new ArrayList(); if (host == null) { throw PSTraceSource.NewArgumentNullException("host"); } if (initialSessionState == null) { throw PSTraceSource.NewArgumentNullException("initialSessionState"); } this._host = host; if (suppressClone) { this._initialSessionState = initialSessionState; } else { this._initialSessionState = initialSessionState.Clone(); } base.ApartmentState = initialSessionState.ApartmentState; this.ThreadOptions = initialSessionState.ThreadOptions; }
public PowerShellSession() { this.SessionState = SMA.Runspaces.InitialSessionState.CreateDefault(); this.RunSpace = SMA.Runspaces.RunspaceFactory.CreateRunspace(this.SessionState); this.RunSpace.Open(); this.PowerShell = SMA.PowerShell.Create(); this.PowerShell.Runspace = this.RunSpace; this.Invoker = new SMA.RunspaceInvoke(this.RunSpace); }
public void CleanUp() { // Make sure we cleanup everything this.PowerShell.Dispose(); this.Invoker.Dispose(); this.RunSpace.Close(); this.Invoker = null; this.RunSpace = null; this.SessionState = null; this.PowerShell = null; }
public void CleanUp() { // Make sure we cleanup everything this.PowerShell.Dispose(); this.Invoker.Dispose(); this.RunSpace.Close(); this.Invoker = null; this.RunSpace = null; this.SessionState = null; this.PowerShell = null; }
/// <summary> /// Report that a new local session (runspace) is created /// </summary> internal static void ReportLocalSessionCreated( System.Management.Automation.Runspaces.InitialSessionState iss, System.Management.Automation.Host.TranscriptionData transcriptionData) { bool isConstrained = (iss != null) && (iss.DefaultCommandVisibility != SessionStateEntryVisibility.Public) && (iss.LanguageMode != PSLanguageMode.FullLanguage); bool isTranscripting = (transcriptionData != null) && (transcriptionData.SystemTranscript != null); TelemetryWrapper.TraceMessage("PSNewLocalSession", new { Constrained = isConstrained, Transcripting = isTranscripting }); }
public PowerShellSession(System.Reflection.Assembly module) { this.SessionState = SMA.Runspaces.InitialSessionState.CreateDefault(); // Find the path to the assembly var modules = new[] { module.Location }; this.SessionState.ImportPSModule(modules); this.RunSpace = SMA.Runspaces.RunspaceFactory.CreateRunspace(this.SessionState); this.RunSpace.Open(); this.PowerShell = SMA.PowerShell.Create(); this.PowerShell.Runspace = this.RunSpace; this.Invoker = new SMA.RunspaceInvoke(this.RunSpace); }
public PowerShellTestsSession() { this.SessionState = System.Management.Automation.Runspaces.InitialSessionState.CreateDefault(); // Get path of where everything is executing so we can find the VisioPS.dll assembly var executing_assembly = System.Reflection.Assembly.GetExecutingAssembly(); var asm_path = System.IO.Path.GetDirectoryName(executing_assembly.GetName().CodeBase); var uri = new System.Uri(asm_path); var visio_ps = System.IO.Path.Combine(uri.LocalPath, "VisioPS.dll"); var modules = new[] { visio_ps }; // Import the latest VisioPS module into the PowerShell session this.SessionState.ImportPSModule(modules); this.RunSpace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(this.SessionState); this.RunSpace.Open(); this.PowerShell = System.Management.Automation.PowerShell.Create(); this.PowerShell.Runspace = this.RunSpace; this.Invoker = new System.Management.Automation.RunspaceInvoke(this.RunSpace); }
public PowerShellTestsSession() { this.SessionState = System.Management.Automation.Runspaces.InitialSessionState.CreateDefault(); // Get path of where everything is executing so we can find the VisioPS.dll assembly var executing_assembly = System.Reflection.Assembly.GetExecutingAssembly(); var asm_path = System.IO.Path.GetDirectoryName(executing_assembly.GetName().CodeBase); var uri = new System.Uri(asm_path); var visio_ps = System.IO.Path.Combine(uri.LocalPath, "VisioPS.dll"); var modules = new[] { visio_ps }; // Import the latest VisioPS module into the PowerShell session this.SessionState.ImportPSModule(modules); this.RunSpace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(this.SessionState); this.RunSpace.Open(); this.PowerShell = System.Management.Automation.PowerShell.Create(); this.PowerShell.Runspace = this.RunSpace; this.Invoker = new System.Management.Automation.RunspaceInvoke(this.RunSpace); }
protected RunspaceBase (PSHost host, System.Management.Automation.Runspaces.RunspaceConfiguration runspaceConfiguration) { this._version = PSVersionInfo.PSVersion; this._runspaceStateInfo = new System.Management.Automation.Runspaces.RunspaceStateInfo (System.Management.Automation.Runspaces.RunspaceState.BeforeOpen); this._syncRoot = new object (); this._runspaceEventQueue = new Queue<RunspaceEventQueueItem> (); this.RunspaceOpening = new ManualResetEventSlim (false); this._runningPipelines = new ArrayList (); if (host == null) { throw PSTraceSource.NewArgumentNullException ("host"); } if (runspaceConfiguration == null) { throw PSTraceSource.NewArgumentNullException ("runspaceConfiguration"); } this._host = host; this._runspaceConfiguration = runspaceConfiguration; if (this._runspaceConfiguration.ImportSystemModules) { this._initialSessionState = InitialSessionState.CreateDefault (); ImportSystemModules (); } }
protected RunspaceBase(PSHost host, System.Management.Automation.Runspaces.InitialSessionState initialSessionState) { this._version = PSVersionInfo.PSVersion; this._runspaceStateInfo = new System.Management.Automation.Runspaces.RunspaceStateInfo(System.Management.Automation.Runspaces.RunspaceState.BeforeOpen); this._syncRoot = new object(); this._runspaceEventQueue = new Queue<RunspaceEventQueueItem>(); this.RunspaceOpening = new ManualResetEventSlim(false); this._runningPipelines = new ArrayList(); if (host == null) { throw PSTraceSource.NewArgumentNullException("host"); } if (initialSessionState == null) { throw PSTraceSource.NewArgumentNullException("initialSessionState"); } this._host = host; this._initialSessionState = initialSessionState.Clone(); base.ApartmentState = initialSessionState.ApartmentState; this.ThreadOptions = initialSessionState.ThreadOptions; }
public void CleanUp() { // Make sure we cleanup everything if (this._powershell != null) { this._powershell.Dispose(); this._powershell = null; } if (this._invoker != null) { this._invoker.Dispose(); this._invoker = null; } if (this._runspace != null) { this._runspace.Close(); this._runspace = null; } this._sessionstate = null; }
protected RunspaceBase(PSHost host, System.Management.Automation.Runspaces.RunspaceConfiguration runspaceConfiguration) { this._version = PSVersionInfo.PSVersion; this._runspaceStateInfo = new System.Management.Automation.Runspaces.RunspaceStateInfo(System.Management.Automation.Runspaces.RunspaceState.BeforeOpen); this._syncRoot = new object(); this._runspaceEventQueue = new Queue <RunspaceEventQueueItem> (); this.RunspaceOpening = new ManualResetEventSlim(false); this._runningPipelines = new ArrayList(); if (host == null) { throw PSTraceSource.NewArgumentNullException("host"); } if (runspaceConfiguration == null) { throw PSTraceSource.NewArgumentNullException("runspaceConfiguration"); } this._host = host; this._runspaceConfiguration = runspaceConfiguration; if (this._runspaceConfiguration.ImportSystemModules) { this._initialSessionState = InitialSessionState.CreateDefault(); ImportSystemModules(); } }
internal RunspacePool(int minRunspaces, int maxRunspaces, System.Management.Automation.Runspaces.InitialSessionState initialSessionState, PSHost host) { this.syncObject = new object(); this.internalPool = new RunspacePoolInternal(minRunspaces, maxRunspaces, initialSessionState, host); }