VMware
5 Replies Last post: Sep 30, 2008 11:33 AM by LucD  

Input requested: Should Get-* cmdlets ever require arguments? posted: Sep 30, 2008 8:34 AM

Click to view c_shanklin's profile Master 754 posts since
Dec 3, 2007
Currently Get-VM will return all VMs.

On the other hand, Get-VirtualSwitch does not return all virtual switches. Instead you must specify a VMHost or VM argument that causes a subset to be returned. Does anyone prefer this behavior? Would it cause problems if Get-VirtualSwitch returned all virtual switches, even given the fact that you may have a lot of virtual switches with different names across different hosts?

To take it even farther, should Get-HardDisk return all hard disks, along with a pointer to the VM that owns them?

Thoughts?
Click to view LucD's profile Champion 2,431 posts since
Oct 31, 2005
Could the 'uniqueness' of the object be a good criteria ?
In other words, which is the highest parent object on which I can not create a 2nd object with the same name ?

For a VM that would be the VC.
For a vswitch that would be the host.
For a harddisk that would be the VM.

If there is no 'default' parent object (host, VM...) the parent has to be passed to the Get- cmdlet.
So no returning all objects for Get-VirtualSwitch and Get-Harddisk for me.
Click to view halr9000's profile Master 814 posts since
Jun 7, 2007
On the other hand, Get-VirtualSwitch does not return all virtual switches. Instead you must specify a VMHost or VM argument that causes a subset to be returned. Does anyone prefer this behavior? Would it cause problems if Get-VirtualSwitch returned all virtual switches, even given the fact that you may have a lot of virtual switches with different names across different hosts?

Currently, this is how Get-Folder works. You will often have dupe
folder names in a virtual center (especially the built-in "vm"
folder). I've never had the thought, "I wish Get-Folder gave me fewer
results". But I do think it can be difficult to match the folders to
their parents which is an area I think you guys could improve by
adding reference (parent) properties.

To take it even farther, should Get-HardDisk return all hard disks, along with a pointer to the VM that owns them?

I'm leaning towards being all-inclusive with filternig being optional
based on a Name (or other parameter). However, every time you do this
you (virtually) create a new flat namespace which can add confusion.

I don't have the right answer. :(
Click to view halr9000's profile Master 814 posts since
Jun 7, 2007
Some other examples, it's pretty easy to have Resource Pools with identical names, and it is even possible to have duplicate VM names under some circumstances.

VM names are unique only per datacenter IIRC? You can certainly have
multiple datacenters per VirtualCenter. And it could go even
larger--you can stack VCs with the Server parameter.

Get-VirtualPortGroup "App Group" | Set-VirtualPortGroup -vlan 100

I'm sold by this one example. You will often have duplicate network
(portgroup) names on purpose in multi-homed environments. Think of
how huge that command is. The guys with physical servers and switches
will be SOOO jealous.

+1





Author of the upcoming book: Managing VMware Infrastructure with PowerShell
Co-Host, PowerScripting Podcast (http://powerscripting.net)
Click to view LucD's profile Champion 2,431 posts since
Oct 31, 2005
I thought one of the nice features of PowerShell was that you could 'read' a line practically as plain English (wasn't that the purpose of the verb-noun format ?).
In the example I would need to 'know' how large the default scope of the cmdlet was to understand what was being done.

I prefer something like this
Get-Cluster MyCluster | Get-VirtualPortGroup "App Group" | Set-VirtualPortGroup -vlan 100

That way I 'see' that I'm doing this against all port groups, called "App Group", in the cluster, irrespective of the number of hosts in the cluster
And my network admins will still be jealous ;-)

Hence my remark to have no default scope for the Get-VirtualSwitch, Get-Harddisk... type cmdlets.

VMware Developer

SDKs, APIs, Videos, Learn and much more in the Developer community.

Learn More

Developer Sample Code

Increase your developer productivity with VMware API sample code.

Learn More

VMworld Sessions & Labs

Online access to the latest VMworld Sessions & Labs and online services.

Learn more

Purchase PSO Credits Online

Purchase credits to redeem training and consulting services online.

Buy Now

Community Hardware Software

View reported configurations or report your own.

Learn More

VMware vSphere

Come witness the next giant leap in virtualization.

Register Today

Communities