internal void CreateDummy(string cmdlet)
 {
     try
     {
         var script = string.Format("Function {0} {{}}", cmdlet);
         _host.Shell.AddScript(script).Invoke();
         _host.HandleNonTerminatingErrors();
     }
     catch (RuntimeException)
     {
         _host.DisposeHost();
         throw;
     }
 }
Beispiel #2
0
        public PsHost Execute(string method, IDictionary parameters = null)
        {
            _host.Shell.AddScript(_scriptBlock);
            _host.Shell.AddCommand(method);
            if (parameters != null)
            {
                _host.Shell.AddParameters(parameters);
            }
            _host.Result = _host.Shell.Invoke();
            var error = _host.HandleNonTerminatingErrors();

            if (!String.IsNullOrEmpty(error))
            {
                _host.Result = new Collection <PSObject> {
                    new PSObject(error)
                };
            }
            return(_host);
        }