コード例 #1
0
        private async Task <bool> PerformPowershellAsync(string command, bool importNavContainerHelper)
        {
            if (asyncScript.InvocationStateInfo.State == PSInvocationState.Running)
            {
                ErrorCallback?.Invoke(this, Resources.GlobalRessources.ErrorWaitForPreviousTask);
                return(false);
            }
            StringBuilder sb = new StringBuilder();

            if (importNavContainerHelper)
            {
                sb.AppendLine("import-module navcontainerhelper");
            }
            sb.AppendLine(command);
            asyncScript.AddScript(sb.ToString());
            StartScriptCallback?.Invoke(this, command);
            var result = asyncScript.BeginInvoke <PSObject, PSObject>(null, pso);
            await Task.Factory.FromAsync(result, x => { });

            if (asyncScript.HadErrors)
            {
                ErrorCallback?.Invoke(this, GlobalRessources.ErrorScriptCompletedWithError);
            }
            EndScriptCallback?.Invoke(this, null);
            return(true);
        }
コード例 #2
0
 private void SendCommandToLog(string command)
 {
     command = Regex.Replace(command, PasswordRegexPattern, m => m.Groups[1] + "****" + m.Groups[3]);
     StartScriptCallback?.Invoke(this, command);
 }