InvokeScript() private static méthode

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
Résultat Collection
Exemple #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]);
        }
Exemple #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());
        }