示例#1
0
        //start threads
        public string StartThreads()
        {
            //set parameters to remoting
            CreateWmiProcess process = new CreateWmiProcess();

            process.ComputerName = ComputerName;
            process.Username     = Username;
            process.Password     = Password;
            process.Domain       = Domain;
            process.WmiTimeout   = WmiTimeout;

            //create temp directory
            process.CreateDirectory(@"\\" + ComputerName + @"\c$\deploy_temp");

            //copy files to temp directory
            process.CopyDirectory(SourceDirectory, @"\\" + ComputerName + @"\c$\deploy_temp");

            //execute remote command
            process.InvokeCommand(@"C:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe -ExecutionPolicy Bypass -File C:\deploy_temp\" + ScriptToRun);

            //grab json files
            string json = process.ImportJSON();

            //remove temp directory
            process.RemoveDirectory(@"\\" + ComputerName + @"\c$\deploy_temp");

            //null process object
            process = null;

            //return json data
            return(json);
        }