State information for ADPRHost.
        /// <summary>
        /// Creates a PowerShell <see cref="Runspace"/> to run a script under.
        /// </summary>
        /// <param name="script">The script to run.</param>
        /// <param name="host">An optional existing PSHost to attach the namespace to.</param>
        /// <returns></returns>
        internal string[] RunScript(string script, ADPRHost host = null)
        {
            Collection <PSObject> results;

            if (host == null)
            {
                var state = new ADPRState();
                host = new ADPRHost(state);
            }
            using (var runspace = (RunspaceFactory.CreateRunspace(host)))
            {
                runspace.Open();
                results = RunScript(runspace, script, true);
                runspace.Close();
            }

            return((from result in results select result.ToString()).ToArray());
        }
Beispiel #2
0
 internal ADPRHost(ADPRState state)
 {
     State = state;
 }
        /// <summary>
        /// Creates a PowerShell <see cref="Runspace"/> to run a script under.
        /// </summary>
        /// <param name="script">The script to run.</param>
        /// <param name="host">An optional existing PSHost to attach the namespace to.</param>
        /// <returns></returns>
        internal string[] RunScript(string script, ADPRHost host = null)
        {
            Collection<PSObject> results;
            if (host == null)
            {
                var state = new ADPRState();
                host = new ADPRHost(state);
            }
            using (var runspace = (RunspaceFactory.CreateRunspace(host)))
            {
                runspace.Open();
                results = RunScript(runspace, script, true);
                runspace.Close();
            }

            return (from result in results select result.ToString()).ToArray();
        }
 internal ADPRHost(ADPRState state)
 {
     State = state;
 }