Exemple #1
0
        public PowerShellScript.Result CreateSession(string ipAddress, string userName, string passwordStr, PowerShellScript.InvokeParameter param)
        {
            var p = new PowerShellScript.InvokeParameter(param);

            p.parameters.Add("ComputerName", ipAddress);
            p.parameters.Add("cred", CreateCredential(userName, passwordStr));

            return(createSession.Invoke(p));
        }
Exemple #2
0
        public PowerShellScript.Result Run(string ipAddress, PowerShellScript.InvokeParameter param)
        {
            PowerShellScript.Result result;

            param.parameters.TryGetValue(ParameterManager.SpecialParamName.UserName, out var userName);
            param.parameters.TryGetValue(ParameterManager.SpecialParamName.UserPassword, out var userPassword);

            var sessionResult = SessionManager.Instance.CreateSession(ipAddress, (string)userName, (string)userPassword, param);
            var session       = sessionResult.objs.FirstOrDefault()?.BaseObject;

            if (session == null)
            {
                result = sessionResult;
            }
            else
            {
                param.parameters.Add(ReservedParameterName.Session, session);
                result = psScript.Invoke(param);
            }


            return(result);
        }