public static void Invoke(string aScript, RunningProcesses runningProcesses)
        {
            Process process = new Process();

            try
            {
                process.StartInfo = new ProcessStartInfo()
                {
                    FileName = $"{Environment.SystemDirectory}\\{ScriptConstants.kPowerShellPath}",
                    RedirectStandardError  = true,
                    RedirectStandardOutput = true,
                    CreateNoWindow         = true,
                    UseShellExecute        = false,
                    Arguments = aScript,
                };
                process.StartInfo.EnvironmentVariables["Path"] = CreatePathEnvironmentVariable();

                var customTidyExecutable = GetCustomTidyPath();

                if (string.IsNullOrWhiteSpace(customTidyExecutable) == false)
                {
                    process.StartInfo.EnvironmentVariables[ScriptConstants.kEnvrionmentTidyPath] = customTidyExecutable;
                }

                process.EnableRaisingEvents = true;
                process.ErrorDataReceived  += DataErrorHandler;
                process.OutputDataReceived += DataHandler;
                process.Exited   += ExitedHandler;
                process.Disposed += ExitedHandler;

                runningProcesses.Add(process);

                process.Start();

                process.BeginErrorReadLine();
                process.BeginOutputReadLine();

                process.WaitForExit();
            }
            catch (Exception e)
            {
                process.EnableRaisingEvents = false;
                process.ErrorDataReceived  -= DataErrorHandler;
                process.OutputDataReceived -= DataHandler;
                process.Exited   -= ExitedHandler;
                process.Disposed -= ExitedHandler;

                process.Close();

                throw e;
            }
        }
        public static Process Invoke(string aScript, RunningProcesses aRunningProcesses)
        {
            Process process = new Process();

            try
            {
                process.StartInfo = new ProcessStartInfo()
                {
                    FileName = $"{Environment.SystemDirectory}\\{ScriptConstants.kPowerShellPath}",
                    RedirectStandardError  = true,
                    RedirectStandardOutput = true,
                    CreateNoWindow         = true,
                    UseShellExecute        = false,
                    Arguments = aScript,
                };
                process.StartInfo.EnvironmentVariables["Path"] = CreatePathEnvironmentVariable();

                process.EnableRaisingEvents = true;
                process.ErrorDataReceived  += DataErrorHandler;
                process.OutputDataReceived += DataHandler;
                process.Exited   += ExitedHandler;
                process.Disposed += ExitedHandler;

                aRunningProcesses.Add(process);

                process.Start();
                process.BeginErrorReadLine();
                process.BeginOutputReadLine();
                process.WaitForExit();
            }
            catch (Exception)
            {
            }
            finally
            {
                process.ErrorDataReceived  -= DataErrorHandler;
                process.OutputDataReceived -= DataHandler;
                process.Exited             -= ExitedHandler;
                process.EnableRaisingEvents = false;
                process.Close();
            }
            return(process);
        }