Search-Cloud is cooler than you might think

PowerCLI 5.0.1 delivered new vCloud Director functionality including a cmdlet named Search-Cloud. If you’ve taken a look at Get-Help Search-Cloud, you’ll see a parameter named -QueryType used to “Specify what types of objects you want to search for”. That’s great, but what types of objects *can* you search for? The help, sadly, isn’t very helpful.

There are a couple different ways to find out. One of them is specific to PowerCLI 5.0.1 and is the Cmdlet Reference. By drilling into the All Cmdlets section and locating Search-Cloud, you’ll see that the parameter named QueryType is of the type QueryType, which is a .NET Enum. Click on the QueryType and you’ll see all the cool things that you can search for using Search-Cloud. Very nice!



There are a few other ways to figure out what the type of parameter -QueryType is, and the expected values. One of them is quite simple, use an invalid -QueryType.

PS C:\>; Search-Cloud -QueryType me
Search-Cloud : Cannot bind parameter 'QueryType'. Cannot convert value "me" to type "VMware.VimAutomation.Cloud.View
s.QueryType" due to invalid enumeration values. Specify one of the following enumeration values and try again. The p
ossible enumeration values are "User, AdminVAppNetwork, AdminUser, BlockingTask, Cell, Host, AdminCatalogItem, Vm, A
dminCatalog, Group, AllocatedExternalAddress, OrgVdcResourcePoolRelation, AdminVApp, DvSwitch, Organization, VAppTem
plate, AdminAllocatedExternalAddress, OrgNetwork, Catalog, VirtualCenter, ResourcePool, Right, StrandedUser, Portgro
up, AdminVM, Media, AdminVAppTemplate, AdminOrgVdc, OrgVdc, CatalogItem, Event, VApp, AdminOrgNetwork, VAppNetwork,
AdminShadowVM, Datastore, ProviderVdc, DatastoreProviderVdcRelation, AdminMedia, ExternalNetwork, NetworkPool, Admin
Group, Task, AdminTask, VAppOrgNetworkRelation, Role, ProviderVdcResourcePoolRelation".
At line:1 char:24
+ Search-Cloud -QueryType <;<;<;<;  me     + CategoryInfo          : InvalidArgument: (:) [Search-Cloud], ParameterBindingException     + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,VMware.VimAutomation.Cloud.Commands.Cmdlets.SearchCloud 

Another would be to find the ParameterType, which shows us it’s VMware.VimAutomation.Cloud.Views.QueryType. This can be accomplished in steps:

 PS C:\>; Get-Command search-Cloud | Select-Object -ExpandProperty Parameters

Key                                Value
---                                -----
Name                               System.Management.Automation.ParameterMetadata
Filter                             System.Management.Automation.ParameterMetadata
QueryType                          System.Management.Automation.ParameterMetadata
Property                           System.Management.Automation.ParameterMetadata
Server                             System.Management.Automation.ParameterMetadata
Verbose                            System.Management.Automation.ParameterMetadata
Debug                              System.Management.Automation.ParameterMetadata
ErrorAction                        System.Management.Automation.ParameterMetadata
WarningAction                      System.Management.Automation.ParameterMetadata
ErrorVariable                      System.Management.Automation.ParameterMetadata
WarningVariable                    System.Management.Automation.ParameterMetadata
OutVariable                        System.Management.Automation.ParameterMetadata
OutBuffer                          System.Management.Automation.ParameterMetadata

And then:

PS C:\>; (Get-Command search-Cloud | Select-Object -ExpandProperty Parameters).QueryType

Name            : QueryType
ParameterType   : VMware.VimAutomation.Cloud.Views.QueryType
ParameterSets   : {[__AllParameterSets, System.Management.Automation.ParameterSetMetadata]}
IsDynamic       : False
Aliases         : {}
Attributes      : {__AllParameterSets, System.Management.Automation.ValidateNotNullOrEmptyAttribute}
SwitchParameter : False


PS C:\>; (Get-Command search-Cloud | Select-Object -ExpandProperty Parameters).QueryType.ParameterType

IsPublic IsSerial Name                      BaseType
-------- -------- ----                      --------
True     True     QueryType                 System.Enum

Now that we know it’s an enum, we can do a couple different things. The code below will list out all the names in the enum.


We’ll get effectively the same information back in this way, too.

[VMware.VimAutomation.Cloud.Views.QueryType] | Get-Member -Static -MemberType Property

#vBrownBag: vCloud Director & the AutoLab

If you listen to or attend the #vBrownBags on a regular basis, then chances are you’ve heard of the AutoLab. If you haven’t, then allow me. DUDE, you should check out the AutoLab! 🙂

The AutoLab is brought to you by APAC vBrownBag host Alastair Cooke (web/twitter), and our mad genius behind the boards, Nick Marshall (web/twitter). Its mission is simple: to provide an easy way to deploy a vSphere lab on ESXi or Workstation. If you have a laptop with about 8GB RAM and a modern CPU, then you can probably run the AutoLab! Sure, it won’t be like running a quad-socket 8 core beast with 1TB of RAM and EFD, but it’ll get you labbing, and that’s all that counts. If you’d like to get started, head over to and download the AutoLab. I won’t go into detail on getting it setup, but I do want to outline a few minor alterations I did to get vCloud Director up and running.

First, I changed up the way Workstation manages the memory. I only have 8GB of RAM in this laptop, so overhead is a bit tight, especially if I’m running my WinXP VM as well, which I use as a personal VM inside my corporately imaged laptop. The AutoLab instructions say to go into Workstation’s Preferences menu and set the memory to “Fit all virtual machine memory into reserved host RAM”, which is essentially a memory reservation within Workstation. That approach works well, and I imagine that it helps to reduce swapping, especially on computers with spinning disks. Since my laptop runs SSD, I wanted to have more VMs running at once without having Workstation complain about running out of memory. I changed the memory setting to “Allow most virtual machine memory to be swapped”.

Another change I had to make was to increase the memory allocated to the Host1 and Host2. Staying with the default 2GB works for vSphere labbing, but once you install vCloud Director, you might want some memory available to power on VMs within vCD. I also went into the DC VM’s DHCP panel and increased the lease times. My reasoning for that is since I’m using the vCloud Director appliance; it does all of it’s setup business based on the DHCP addresses it receives at first power-on. If those addresses change, your vCD won’t run. Sure, you can go in and fix it, but it’s a PITA (IMO), so why bother? 🙂

After your AutoLab is setup, download the vShield Manager and vCloud Director appliances. The vShield Manager appliance has a EULA that goes crazy on my copy of Workstation, so I “fixed” it by unzipping the ova (it’s a zip file, after all, just a different extension), deleting the .mf & .cert files, and removing all the text between the <License> tags within the .ovf file’s XML. Before you delete the EULA, you should probably read and understand what you’ll be agreeing to. 🙂 Don’t bother rezipping into an .ova, just open the .ovf file with Workstation, agree to the now non-existent license (remember, you agreed when you read then deleted it) and let the install complete. Once it finishes, change the network from Bridged to the VMnet3 you created when you deployed the AutoLab, and set the memory to 384MB instead of 3GB. Power on the vShield Manager VM and wait for the startup to complete. Login to the vShield VM using the credentials of admin/default, enter privileged mode with the en command and the password default and type setup. You’ll be presented with a setup wizard of sorts; I used for the IP, for the subnet mask, for the gateway, for DNS, and lab.local for the DNS domain search list. After the vShield Manager setup completes, go over to the DC VM’s DNS panel and create a forward and reverse lookup for the vShield Manager VM, whose hostname will be manager by default. You may also want to setup a DHCP reservation for that IP address (if you want to be extra sure it won’t lose its IP); you can find the vShield Manager’s MAC address by logging into privileged mode and issuing the command show interface.

If you haven’t installed vCD previously, or if you have previous vShield experience outside of vCloud Director, the process is a bit different when using vShield in conjunction with vCenter. First, you won’t need to register your vShield Manager VM within vCenter, as it will be controlled by vCloud Director. Second, if you need to license it for whatever reason, the licensing is handled via vCenter’s Licensing panel. vCenter becomes aware of it once you connect vShield to vCloud Director and vCloud Director is connected to a vCenter.

Next up, open the vCloud Director appliance’s .ova file and add it to Workstation. Be sure to change the two bridged network adapters over to VMnet3, or your appliance will either wait forever for an IP address, or get one from the DHCP server on your Workstation’s LAN. Either way, at this point it’s simpler just to delete the VM and start over. The vCloud Director initial setup will take a while, so be patient until it completes. Interrupting it will most likely break it, so you’ll be back to the “delete and re-install shuffle” if you’re impatient. You’ll know it setup correctly if you can browse to the address displayed on the VM console (minus the 5480 port) and see the vCloud Director setup page.

At this point you can complete the vCloud Director web-based setup, but don’t go so far as to connect vCenter. If you have any troubles with name resolution to either vCenter or your vShield Manager VM, check DNS. When that is done, hop back over to the vCloud Director VM’s console and choose the Configure Network option. Change the hostname to something other than localhost, take note of the IP addresses it pulled from DHCP, save your changes and exit the network configuration screen. Next, choose the Login option, use the root/Default0 credentials and issue the command ifconfig to get the MAC addresses for the network interfaces if you want to do DHCP reservations over on the DC VM. You will want to add forward and reverse DNS records for the vCloud Director VM.

Once all the setup is completed, you can head over to the VC VM and use that to launch the vSphere client and point the browser towards the vCloud Director web page. If the rest of your lab is up and running, feel free to connect vCenter and start building out your provider virtual datacenter.

Happy AutoLabbing!