InvokeScript() приватный статический Метод

Invokes a powershell script using the same runspace as the caller.
private static InvokeScript ( string scriptName, Hashtable parameters ) : Collection
scriptName string script name
parameters System.Collections.Hashtable parameters for the script
Результат Collection
Пример #1
0
        public static PSObject Deserialize(string json)
        {
            if (String.IsNullOrEmpty(json))
            {
                return(null);
            }

            Hashtable parameters = new Hashtable();

            parameters.Add(Constants.PsCommandParamInputObject, json);
            var result = PowerShellJsonConverter.InvokeScript(Constants.PsCommandConvertFromJson, parameters);

            if (result.Count != 1)
            {
                return(null);
            }

            //count == 1. return the first psobject
            return(result[0]);
        }
Пример #2
0
        public static string Serialize(object inputObject)
        {
            if (inputObject == null)
            {
                return(null);
            }

            Hashtable parameters = new Hashtable();

            parameters.Add(Constants.PsCommandParamInputObject, inputObject);
            parameters.Add(Constants.PsCommandParamDepth, Constants.PsCommandValueDepth);
            var result = PowerShellJsonConverter.InvokeScript(Constants.PsCommandConvertToJson, parameters);

            if (result.Count != 1)
            {
                return(null);
            }

            return(result[0].ToString());
        }