VMware PowerCLI

The Best User Interface for your VMware Datacenter!

Support natural PowerShell interactive behavior (tab-completion of possible values based on inventory items in the environment, contributing to discoverability): add tab-completion support to parameter values

PowerShell provides the ability to tab-complete parameter values via argument completers.  For example:

  • Get-Process -Name <tab>
  • Get-Service -DisplayName <tab>
  • Get-Command -Module VMwar<tab>
  • Get-Variable -Name r<tab>
  • etc.

Argument completers for PowerCLI cmdlets can be extremely convenient and helpful, further optimizing the user as they travel through their PowerShell experience for the day.

I am suggesting that we add this support to PowerCLI cmdlets where it is valuable.  A short list of examples:

  • Get-VM -Name matt<tab>
  • Get-VMHost myho<tab>
  • Get-Datastore -VM matt<tab>
  • Get-VDSwitch -VMHost <tab>
  • Get-DrsVMHostRule -VMGroup <tab>
  • ...and so on -- enable tab-completion of parameter values from corresponding vSphere inventory objects

 

The following doc holds several more use cases, both for existing cmdlets in PowerShell, and some example use cases for PowerCLI cmdlets:  https://github.com/mtboren/PowerCLIFeedback/blob/master/PowerCLISuggestions.md (in the "support natural PowerShell interactive behavior" section).  The PowerCLI examples are just the beginning:  we can go through the full catalog of PowerCLI cmdlets and see where argument completers would be applicable and consider which would be most valuable.

 

In addition to being extremely convenient and helpful, and argument completers are a use-at-will feature -- if someone does not want to use them (or is unaware of them), there is no negative impact to resource utilization, cmdlet performance, etc.  Argument completers are only "invoked" when a user tries to tab-complete a parameter that has a registered argument completer.

 

Examples of using Register-ArgumentCompleter to register new argument completers for the current PowerShell session:  https://github.com/mtboren/PowerCLIFeedback/blob/master/RegisterArgumentCompleter_samples.ps1

 

Other info:  Modern PowerShell supports registering argument completers with the Register-ArgumentCompleter cmdlet.  Previous versions of PowerShell also have support for argument completers, as described in various locations around the web.

  • Matt Boren
  • Oct 26 2017
  • Looking for Feedback
  • Attach files
  • Matt Boren commented
    August 26, 2019 19:13

    There is now a great start on implementing this behavior (not affiliated with VMware themselves).  It is available via the PowerShellGallery as the script Register-VNVMwarePowerCLIArgumentCompleter.

     

    You use `Find-Script Register-VNVMwarePowerCLIArgumentCompleter` to find it in the PowerShellGallery, and you use either `Save-Script` or `Install-Script` to make the script available locally.  Then, just run the script once in your PowerShell session, and it registers oodles of argument completers.

     

    The code (including the Docs) is in the repo at https://github.com/vNugglets/PowerShellArgumentCompleters, and you can view in in the PowerShellGallery at https://www.powershellgallery.com/packages/Register-VNVMwarePowerCLIArgumentCompleter