/// <summary>
        /// Executes a powershell script at the supplied path asynchronously.
        /// Output stream data is saved in real time as the script executes.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        private async Task ExecutePowershellScriptAsync(object obj)
        {
            // Disable UI elements
            IsBusy = true;
            scriptReader.SetArgumentsEnabled(false);

            // Add user input to script parameters
            powershellExecuter.SetScriptParameters(ScriptVariables);

            // Execute script asynchronously
            await Task.Run(() =>
            {
                using (PowerShell psInstance = PowerShell.Create())
                {
                    psInstance.AddCommand(SelectedScriptPath);
                    int argLength = powershellExecuter.CommandLineArguments.Count;
                    for (int ii = 0; ii < argLength; ii++)
                    {
                        psInstance.AddParameter(powershellExecuter.CommandLineArgumentKeys[ii], powershellExecuter.CommandLineArguments[ii]);
                    }

                    PSDataCollection <PSObject> outputCollection = new PSDataCollection <PSObject>();

                    // Collect output in real time
                    outputCollection.DataAdded            += OutputCollection_DataAdded;
                    psInstance.Streams.Error.DataAdded    += Error_DataAdded;
                    psInstance.Streams.Progress.DataAdded += Progress_DataAdded;

                    // Begin powershell execution and continue control
                    IAsyncResult result = psInstance.BeginInvoke <PSObject, PSObject>(null, outputCollection);

                    // When wrapping PowerShell instance in a using block, the pipeline will
                    // close and the script execution will abort. Therefore we must wait for
                    // the state of the pipeline to equal Completed
                    while (result.IsCompleted == false)
                    {
                        Thread.Sleep(250);
                        if (CancelScriptExecution)
                        {
                            psInstance.Stop();
                        }
                    }
                }
            });

            IsBusy = false;
            scriptReader.SetArgumentsEnabled(true);
            ClearScriptSession();
        }