public void ExecuteScript(ScriptConfigElement e)
        {
            using (_instance = PowerShell.Create())
            {
                _instance.AddScript(File.ReadAllText(e.PathToScript));

                PSDataCollection <PSObject> outputCollection = new PSDataCollection <PSObject>();
                outputCollection.DataAdded           += outputCollection_DataAdded;
                _instance.Streams.Progress.DataAdded += Progress_DataAdded;
                _instance.Streams.Error.DataAdded    += Error_DataAdded;
                _instance.Streams.Verbose.DataAdded  += Verbose_DataAdded;
                _instance.Streams.Debug.DataAdded    += Debug_DataAdded;
                _instance.Streams.Warning.DataAdded  += Warning_DataAdded;

                IAsyncResult result = _instance.BeginInvoke <PSObject, PSObject>(null,
                                                                                 outputCollection);

                while (result.IsCompleted == false)
                {
                    Thread.Sleep(500);
                }

                foreach (PSObject o in outputCollection)
                {
                    Console.WriteLine(o.GetType());
                    Console.WriteLine(o);
                }
            }
        }
        public static ScriptStat InitScriptStat(ScriptConfigElement e)
        {
            ScriptStat ss;

            if (_stats.ContainsKey(e.PathToScript))
            {
                ss = _stats[e.PathToScript];
            }
            else
            {
                ss        = new ScriptStat();
                ss.Script = e.PathToScript;
                ss.Type   = e.Type;
            }

            return(ss);
        }