Exemplo n.º 1
0
        /// <summary>
        /// Executes a powershell script at the supplied path with the supplied
        /// input variables. Saves normal and error output from the script.
        /// </summary>
        /// <param name="obj"></param>
        private void ExecutePowershellScript(object obj)
        {
            try
            {
                powershellExecuter.ExecuteScript(SelectedScriptPath, ScriptVariables);
            }
            catch (Exception e)
            {
                Models.PsGuiException.WriteErrorToFile(e.ToString());
                Models.PsGuiException.WriteErrorToScreen("Script execution failed due to bad PowerShell script code!");
            }

            // Outdated since async implemented
            // ScriptExecutionOutputStandard = powershellExecuter.ScriptExecutionOutput;
            ScriptExecutionErrorException = powershellExecuter.ScriptExecutionErrorException;
            ClearScriptSession();
        }