Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update xNew-VM -> New-xVM, increasing ease of use and discoverability #55

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

mtboren
Copy link

@mtboren mtboren commented Jan 23, 2018

Another great function by you, William. I took the opportunity to increase the ease of use of the function, and added most of the PowerShell features that we all appreciate in a standard function/cmdlet. The updates (also listed in the comments in the updated .ps1):

Updates added Jan 2018 by Matt Boren:

  • improve ease of use: can get going with as few as four (4) parameters to function, now, vs. a dozen or more (by gleaning info from the values of the few mandatory parameters, and reduction in overall parameter count)
  • use approved verb for function name
  • add -TrustAllCert switch parameter to give user option as to whether they want to disable SSL certificate checking, instead of disabling SSL cert checking regardless
  • take source VM from object from pipeline
  • default to source VM name for dest VM name if no dest VM name specified
  • simplify cluster/resourcepool parameters: remove need for -Cluster, and set default value for ResourcePool, so as to reduce number of parameters needed
  • simplify specifying destination vCenter -- glean this info from the -VMHost object, instead of requiring user to additionally specify the name of the destination vCenter
  • simplify Datacenter parameter (remove it): glean this info from the -VMHost object, too
  • add pipeline support to take pertinent values from pipeline (-SourceVM)
  • optimize array creation code (just assign collection of values to array variable, instead of potentially more resource-expensive array concatenation (which actually create a new, 1-item larger array for every item addition))
  • get items for credential for ServiceLocatorNamePassword from destination vCenter connection object (Client.Config)
  • improve new-object creation for use in CloneVM task (creation of fewer additional interim variables, clean up overall syntax)
  • correct logic around upper-casing the vC UUID value (was reversed)
  • improve snapshot selection (limit scope to source VM, instead of "get snapshot by name in all of source vC", which may return multiple snapshots)
  • return a Task object, so that user can update task to track progress (via their own Get-Task calls)
  • sort out variable naming in function (had issues where global-scope variables were used inside of the function instead of the corresponding function parameters, like $destVCConn was being used instead of the parameter $destvc)
  • add -WhatIf support
  • complete the comment-based help, so that Get-Help <cmdlet> will return fully useful help (with examples and whatnot), as expected

Let's discuss any of the updates. Hopefully we can make the world even that much better of a place with these feature adds! And, I put an example of the simplified syntax at the bottom of the commit.

Cheers, Matt Boren

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant