private void Powercli_Click(object sender, EventArgs e) { RunspaceConfiguration config = RunspaceConfiguration.Create(); Runspace runspace = RunspaceFactory.CreateRunspace(config); // open it runspace.Open(); try { // import PowerCLI ViCore snapin PSSnapInException warning; config.AddPSSnapIn("VMware.VimAutomation.Core", out warning); if (warning != null) { throw warning; } // create a pipeline and feed it the script text Pipeline pipeline = runspace.CreatePipeline(); // Create Command to Set Na Option var access = new Command("Connect-VIServer"); access.Parameters.Add("Server", "192.168.123.108"); access.Parameters.Add("Protocol", "https"); access.Parameters.Add("User", "root"); access.Parameters.Add("Password", "assign"); // Add Command to Pipeline pipeline.Commands.Add(access); //Execute by invoking pipeline.Invoke(); } finally { runspace.Close(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)