public void Connect()
        {
            if (_runspace == null)
            {
                InitializeRunspace();
            }

            if (_connectMsolService == null)
            {
                InitializeConnectMsolService();
            }

            _isConnect = false;

            //Create Pipeline and add teh command
            Pipeline pipeline = _runspace.CreatePipeline();

            pipeline.Commands.Add(MsolCmdletExtensions.ToCommand(_connectMsolService));

            //Invoke the command and return the results
            //Invoke the commands and return the results and errors
            ICollection <PSObject> results = pipeline.Invoke();

            if (pipeline.Error.Count == 0)
            {
                _isConnect = true;
            }
        }
        public ICollection <PSObject> PipelineInvoke(IMsolCmdlet command)
        {
            //Create Runspace if it has not already been created
            if (_runspace == null)
            {
                InitializeRunspace();
            }

            //Create Pipeline and add teh command
            Pipeline pipeline = _runspace.CreatePipeline();

            pipeline.Commands.Add(MsolCmdletExtensions.ToCommand(command));

            //Invoke the command and return the results
            return(pipeline.Invoke());
        }
        public ICollection <PSObject> PipelineInvoke(Collection <IMsolCmdlet> commands)
        {
            //Create Runspace if it has not already been created
            if (_runspace == null)
            {
                InitializeRunspace();
            }

            //Create Pipeline and add the commands
            Pipeline pipeline = _runspace.CreatePipeline();

            foreach (IMsolCmdlet item in commands)
            {
                pipeline.Commands.Add(MsolCmdletExtensions.ToCommand(item));
            }

            //Invoke the commands and return the results
            return(pipeline.Invoke());
        }
        public ICollection <PSObject> PipelineInvoke(IMsolCmdlet command, out PipelineReader <object> Errors)
        {
            //Create Runspace if it has not already been created
            if (_runspace == null)
            {
                InitializeRunspace();
            }

            //Create Pipeline and add the command
            Pipeline pipeline = _runspace.CreatePipeline();

            pipeline.Commands.Add(MsolCmdletExtensions.ToCommand(command));

            //Invoke the command and return the results and errors

            ICollection <PSObject> results = pipeline.Invoke();

            Errors = pipeline.Error;

            pipeline = null;

            return(results);
        }