Quantcast
Channel: VMware Communities: Message List - vSphere Management SDK
Viewing all articles
Browse latest Browse all 2052

Object is NULL if querying a VM with brackets in DisplayName

$
0
0

Hello everybody,

 

I just started using the VimClient with C#/.NET

I have the following code:

 

        VimClient client = new VimClient();
        client.Connect(serviceUrl);
        client.Login(userName, password);
        NameValueCollection filter = new NameValueCollection();

 

      
        int countCheckedVMs = clbVMsToolsNeedUpgrade.CheckedItems.Count - 1;
        for (int i = 0; i <= countCheckedVMs; i++ )
        {
            string displayName = clbVMsToolsNeedUpgrade.CheckedItems[i].ToString();

 

            filter.Add("Config.Name", displayName);
            MessageBox.Show(filter[0].ToString());
          
            IList<EntityViewBase> vmList = client.FindEntityViews(typeof(VirtualMachine), null, filter, null);
          
            foreach (VirtualMachine vm in vmList)
            {
                vm.UpgradeTools("/S /v\"/qn REBOOT=ReallySuppress\"");
                rtbLog.AppendText("VMware Tools-Upgrade for VM " + displayName + " started\n");
            }
          

 

            filter.Remove("Config.Name");
                       
        }
          

 

        client.Disconnect();

 

This is working good until it comes to a VM which has brackets in its displayname.

So a VM called "My Server" is working but not "My Server (rellay)"

I have no idea why, cant the VimClient handle the brackets?


Viewing all articles
Browse latest Browse all 2052

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>