Get Datetime of ESX server in C# -
i'm looking easy way date , time of esx server in c#. has hardware time, think bios time. when vm reboots gets time of bios time. time want datetime object.
i think should use this:
private datetime gettimeesx(machine machine) { datetime time = new datetime(); runspace runspace = runspacefactory.createrunspace(); runspace.open(); pipeline pipeline = runspace.createpipeline(); command getesxcli = new command("get-esxcli"); getesxcli.parameters.add("server", machine.ip); command getsystime = new command("system time get"); pipeline.commands.add(getesxcli); pipeline.commands.add(getsystime); collection<psobject> output = pipeline.invoke(); foreach (psobject psobject in output) { time = (datetime)psobject.baseobject; } return time; }
does has idea how test this? don't have esx running in network.
since docs show powershell cmdlets, have translate c# yourself. can following:
- obtain
esxcli
accessor, usingget-esxcli
- use
system time get
command.
Comments
Post a Comment