PSHost implementation for AppDomainPowerShellRunner.
Based on the msdn page Writing a Windows PowerShell Host Application
Inheritance: System.Management.Automation.Host.PSHost
        /// <summary>
        /// Creates a PowerShell <see cref="Runspace"/> to run a script under.
        /// </summary>
        /// <param name="file">The name of the text file to run as a powershell script.</param>
        /// <param name="host">An optional existing PSHost to attach the namespace to.</param>
        /// <exception cref="FileNotFoundException">Thrown if the <paramref name="file"/> does not exist.</exception>
        /// <returns></returns>
        internal string[] RunScript(Uri file, ADPRHost host = null)
        {
            if (!File.Exists(file.LocalPath))
            {
                throw new FileNotFoundException("PowerShell script not found", file.AbsolutePath);
            }

            var script = File.ReadAllText(file.LocalPath);

            return(RunScript(script, host));
        }
        /// <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());
        }
        /// <summary>
        /// Creates a PowerShell <see cref="Runspace"/> to run a script under.
        /// </summary>
        /// <param name="file">The name of the text file to run as a powershell script.</param>
        /// <param name="host">An optional existing PSHost to attach the namespace to.</param>
        /// <exception cref="FileNotFoundException">Thrown if the <paramref name="file"/> does not exist.</exception>
        /// <returns></returns>
        internal string[] RunScript(Uri file, ADPRHost host = null)
        {
            if (!File.Exists(file.LocalPath))
            {
                throw new FileNotFoundException("PowerShell script not found", file.AbsolutePath);
            }

            var script = File.ReadAllText(file.LocalPath);
            return RunScript(script, host);
        }
        /// <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();
        }