ConnectVIServer and power on a VM using C#.Net assemblies

ConnectVIServer and power on a VM using C#.Net assemblies

Hi ,

i have installed the VSphere Client Ver4.1.0.

i want to create a simple C# application which connnect to this VSphere Client, and power on a Virtual mahcine, and after that Virtual mahcine will be powered off and disconnect the connection from VSphere Client.

i have installed vSphere PowerCLI, and below is the dlls versions.

VMware.VimAutomation.ViCore.Cmdlets.dll ver 4.1.0.2519

VMware.VimAutomation.ViCore.Impl.dll ver 4.1.0.2519

VMware.VimAutomation.ViCore.Interop.dll ver 4.1.0.2519

VMware.VimAutomation.ViCore.Types.dll ver 4.1.0.2519

VMware.VimAutomation.ViCore.Util10.dll ver 4.1.0.2519

VMware.VimAutomation.ViCore.Util10Ps.dll ver 4.1.0.2519

i am able to connect to the VSphere client using the below code but how to power on a particular virtual machine is problem kindly can anybody give sample application or guidance.

try

{

ConnectVIServer ConnectServer = new ConnectVIServer();

ConnectServer.User = "corp
James";

ConnectServer.Password = "James@007";

ConnectServer.Protocol = "https";

ConnectServer.Server[0] = "dev.MyClient.com";

ConnectServer.Invoke();

///Till this step i dont have any problem, because i have connected to the VSphere client.

//from below step i am unable to point to a virtual machine to power it on.

StartVM PoweredOnVM = new StartVM();

DisconnectVIServer DisConnect = new DisconnectVIServer();

DisConnect.Invoke();

}

if i am doing any thing wrong kindly guide me in proper way.

Thanks in advance,

Shaik.

Version history
Revision #:
1 of 1
Last update:
‎10-05-2010 06:17 AM
Updated by: