private string StringToWrite(HostServiceTicket serviceTicket)
        {
            StringBuilder datatowrite = new StringBuilder("");

            datatowrite.Append("CIM Host Service Ticket Information");
            datatowrite.Append(System.Environment.NewLine);
            datatowrite.Append("Service        : ");
            datatowrite.Append(serviceTicket.service);
            datatowrite.Append(System.Environment.NewLine);
            datatowrite.Append("Service Version: ");
            datatowrite.Append(serviceTicket.serviceVersion);
            datatowrite.Append(System.Environment.NewLine);
            datatowrite.Append("Session Id     : ");
            datatowrite.Append(serviceTicket.sessionId);
            datatowrite.Append(System.Environment.NewLine);
            datatowrite.Append("SSL Thumbprint : ");
            datatowrite.Append(serviceTicket.sslThumbprint);
            datatowrite.Append(System.Environment.NewLine);
            datatowrite.Append("Host           : ");
            datatowrite.Append(serviceTicket.host);
            datatowrite.Append(System.Environment.NewLine);
            datatowrite.Append("Port           : ");
            datatowrite.Append(serviceTicket.port != 0 ? serviceTicket.port.ToString() : "");
            datatowrite.Append(System.Environment.NewLine);
            Console.WriteLine(datatowrite.ToString());
            return(datatowrite.ToString());
        }
 private string StringToWrite(HostServiceTicket serviceTicket)
 {
     StringBuilder datatowrite = new StringBuilder("");
     datatowrite.Append("CIM Host Service Ticket Information");
     datatowrite.Append(System.Environment.NewLine);
     datatowrite.Append("Service        : ");
     datatowrite.Append(serviceTicket.service);
     datatowrite.Append(System.Environment.NewLine);
     datatowrite.Append("Service Version: ");
     datatowrite.Append(serviceTicket.serviceVersion);
     datatowrite.Append(System.Environment.NewLine);
     datatowrite.Append("Session Id     : ");
     datatowrite.Append(serviceTicket.sessionId);
     datatowrite.Append(System.Environment.NewLine);
     datatowrite.Append("SSL Thumbprint : ");
     datatowrite.Append(serviceTicket.sslThumbprint);
     datatowrite.Append(System.Environment.NewLine);
     datatowrite.Append("Host           : ");
     datatowrite.Append(serviceTicket.host);
     datatowrite.Append(System.Environment.NewLine);
     datatowrite.Append("Port           : ");
     datatowrite.Append(serviceTicket.port != 0 ? serviceTicket.port.ToString() : "");
     datatowrite.Append(System.Environment.NewLine);
     Console.WriteLine(datatowrite.ToString());
     return datatowrite.ToString();
 }
        private void AcquireInfo()
        {
            string hostName = cb.get_option("host");
            string info     = cb.get_option("info");
            string fileName = cb.get_option("file");
            ManagedObjectReference hostmor = cb._svcUtil.getEntityByName("HostSystem", hostName);

            if (hostmor == null)
            {
                String msg = "Failure: Host [" + hostName + "] not found";
                throw new Exception(msg);
            }
            if ((info == null) || (info.Equals("cimticket")))
            {
                HostServiceTicket serviceTicket =
                    cb._connection._service.AcquireCimServicesTicket(hostmor);
                if (serviceTicket != null)
                {
                    String datatoWrite = StringToWrite(serviceTicket);
                    WriteToFile(datatoWrite, fileName);
                }
            }
            else
            {
                Console.WriteLine("Support for info " + info + " not implemented.");
            }
        }