WahlNetwork / vester

Easily validate and remediate your vSphere configuration
https://wahlnetwork.com
Apache License 2.0
146 stars 45 forks source link

Method of targeting scope #113

Open brianbunke opened 7 years ago

brianbunke commented 7 years ago

Currently, filtering each scope consists of Get-VM -Name YOURINPUTHERE & similar for other scopes.

That's ok, but leaves room for improvement. For example, Get-VM -Tag YOURTAGHERE would be a pretty sweet option.

Is that enough? Should we allow people to fully craft their own queries? That would allow Get-VM | Where Name -notlike 'abc'. Get-VM -Datastore YOURDATASTOREHERE is also a thing. Get-VM may have another useful parameter, or more useful parameters in the future. Who knows how many useful filtering parameters exist on the rest of the scopes right now.

However, currently, we're actually doing:

Get-Datacenter -Name $cfg.scope.datacenter -Server $cfg.vcenter.vc |
    Get-Cluster -Name $cfg.scope.cluster |
    Get-VM -Name $cfg.scope.vm

Will people know to replicate that, or realize that parent scopes may not apply? We could display, on-screen, the results of your query (like after you set it in New-VesterConfig), but some people have thousands of VMs, so I've held off on doing that.

I personally think inventory tags are sweet, and enough to solve this problem. But I'm interested in your feedback before I get started!

midacts commented 7 years ago

I think it is a good idea to allow for custom filtering. I personally like the Get-VM | Where-Object {"server1","server2" -notcontains $_.Name} (Because not many people use tags where I work. I can't trust our admins to tag things appropriately)

brianbunke commented 7 years ago

Another option that we discussed in the Slack channel last night:

Get-VM | Where Name -ne 'asdf' | Invoke-Vester

Accepting piped VIObjects would either overwrite the scope settings in your config file on that run, or completely eliminate them.