Example #1
1
 public static Runspace CreateRunspace()
 {
     PSHost host = new DefaultHost(Thread.CurrentThread.CurrentCulture, Thread.CurrentThread.CurrentUICulture);
     return CreateRunspace(host);
 }
Example #2
0
 public static Runspace CreateRunspace(RunspaceConfiguration runspaceConfiguration)
 {
     if (runspaceConfiguration == null)
     {
         throw PSTraceSource.NewArgumentNullException("runspaceConfiguration");
     }
     PSHost host = new DefaultHost(Thread.CurrentThread.CurrentCulture, Thread.CurrentThread.CurrentUICulture);
     return CreateRunspace(host, runspaceConfiguration);
 }
Example #3
0
 public static Runspace CreateRunspace(InitialSessionState initialSessionState)
 {
     if (initialSessionState == null)
     {
         throw PSTraceSource.NewArgumentNullException("initialSessionState");
     }
     PSHost host = new DefaultHost(Thread.CurrentThread.CurrentCulture, Thread.CurrentThread.CurrentUICulture);
     return CreateRunspace(host, initialSessionState);
 }
		private ExecutionContext GetExecutionContext()
		{
			CultureInfo currentCulture = CultureInfo.CurrentCulture;
            PSHost hostInterface =  new DefaultHost(currentCulture,currentCulture);
            RunspaceConfiguration runspaceConfiguration =  RunspaceConfiguration.Create();
            InitialSessionState iss = InitialSessionState.CreateDefault2();
            AutomationEngine engine = new AutomationEngine(hostInterface, runspaceConfiguration, iss);
            ExecutionContext executionContext = new ExecutionContext(engine, hostInterface, iss);
			return executionContext;
		}
Example #5
0
 public void TestDrives()
 {
     CultureInfo currentCulture = CultureInfo.CurrentCulture;
     PSHost hostInterface =  new DefaultHost(currentCulture,currentCulture);
     RunspaceConfiguration runspaceConfiguration =  RunspaceConfiguration.Create();
     InitialSessionState iss = InitialSessionState.CreateDefault2();
     AutomationEngine engine = new AutomationEngine(hostInterface, runspaceConfiguration, iss);
     ExecutionContext executionContext = new ExecutionContext(engine, hostInterface, iss);
     SessionStateInternal sessionState = new SessionStateInternal(executionContext);
     Collection<PSDriveInfo> drives = sessionState.Drives(null);
     Assert.NotNull(drives);
 }
Example #6
0
        /// <summary>
        /// Creates a runspace using host of type <see cref="DefaultHost"/>. 
        /// This runspace is created using the <see cref="RunspaceConfiguration"/> information 
        /// from EntryAssembly.
        /// </summary>
        /// <returns>
        /// A runspace object.
        /// </returns>
        public static Runspace CreateRunspace()
        {
            PSHost host = new DefaultHost(CultureInfo.CurrentCulture, CultureInfo.CurrentUICulture);

            return CreateRunspace(host);
        }