A V3 PowerShell module to improve tab expansion and Intellisense
PowerShell
Permalink
Failed to load latest commit information.
Snippets Update to ISE code snippet for "Argument Caching" (#75) Jun 21, 2016
SupportTools Add native command tree support for argument completion Feb 15, 2013
.gitattributes Add basic .gitignore and .gitattributes files. Nov 14, 2012
.gitignore Add basic .gitignore and .gitattributes files. Nov 14, 2012
Appx.ArgumentCompleters.ps1 Update Install.ps1 w/ new files and rename to match module-ArgumentCo… May 2, 2016
BitsTransfer.ArgumentCompleters.ps1 Support for module 'BitsTransfer' (#57) May 11, 2016
CimCmdlets.ArgumentCompleters.ps1 Use static registration to speed up module load Jul 13, 2015
Convert-ArgumentCompleterRegistrationScript.ps1 Remove warning about *PrivateData commands Jul 28, 2015
DFSR.ArgumentCompleters.ps1 Argument Completers for module 'DFSR' (#58) May 11, 2016
DhcpServer.ArgumentCompleters.ps1 Support for argument caching (#74) Jun 21, 2016
Dism.ArgumentCompleters.ps1 Use static registration to speed up module load Jul 13, 2015
DnsClient.ArgumentCompleters.ps1 Use static registration to speed up module load Jul 13, 2015
DnsServer.ArgumentCompleters.ps1 Argument Completers for PS module 'DnsServer' (#59) May 11, 2016
FailoverClusters.ArgumentCompleters.ps1 Update FailoverClusters.ArgumentCompletersps1 May 9, 2016
GroupPolicy.ArgumentCompleters.ps1 Update GroupPolicy.ArgumentCompleters.ps1 - GPStarterGPO GUID bug Apr 18, 2016
Hexo.ArgumentCompleters.ps1 add compeletion for hexo (#69) Jun 20, 2016
Hyper-V.ArgumentCompleters.ps1 Use static registration to speed up module load Jul 13, 2015
ISE.ArgumentCompleters.ps1 Remove attribute based registration Jul 10, 2015
Install.ps1 Update install.ps1 - fixes #63 Jun 21, 2016
License.txt Add license May 7, 2014
Microsoft.Azure.ArgumentCompleters.ps1 Hard code commands in Azure module to speed up loading Jul 28, 2015
Microsoft.AzureRm.ArgumentCompleters.ps1 update to filter locations before creating CompletionResults Dec 14, 2015
Microsoft.PowerShell.Core.ArgumentCompleters.ps1 Import-Module completer: auto-complete ...\dirName\dirName.psd1. (#76) Dec 14, 2016
Microsoft.PowerShell.Diagnostics.ArgumentCompleters.ps1 Remove attribute based registration Jul 10, 2015
Microsoft.PowerShell.LocalAccounts.ArgumentCompleters.ps1 'Microsoft.PowerShell.LocalAccounts.ArgumentCompleters' Argument Comp… Jun 11, 2016
Microsoft.PowerShell.Management.ArgumentCompleters.ps1 Use static registration to speed up module load Jul 13, 2015
Microsoft.PowerShell.Utility.ArgumentCompleters.ps1 Fix one-time initialization for completing com classes Jul 28, 2015
NetAdapter.ArgumentCompleters.ps1 Use static registration to speed up module load Jul 13, 2015
NetLbfo.ArgumentCompleters.ps1 Update Install.ps1 w/ new files and rename to match module-ArgumentCo… May 2, 2016
NetQos.ArgumentCompleters.ps1 Update Install.ps1 w/ new files and rename to match module-ArgumentCo… May 2, 2016
NetSecurity.ArgumentCompleters.ps1 Use static registration to speed up module load Jul 13, 2015
NetTCPIP.ArgumentCompleters.ps1 Use static registration to speed up module load Jul 13, 2015
Pnpdevice.ArgumentCompleters.ps1 Argument Completers for Pnpdevice module (#51) May 2, 2016
PowerShellDirect.ArgumentCompleters.ps1 PowerShell Direct Argument Completer (#67) Jun 11, 2016
PowerShellWebAccess.ArgumentCompleters.ps1 Remove attribute based registration Jul 10, 2015
PrintManagement.ArgumentCompleters.ps1 Hard code commands in PrintManagement completers Jul 29, 2015
README.md More readme updates and fix typo Nov 15, 2015
RobocopyExe.ArgumentCompleters.ps1 Remove attribute based registration Jul 10, 2015
ScheduledTasks.ArgumentCompleters.ps1 Use static registration to speed up module load Jul 13, 2015
SmbShare.ArgumentCompleters.ps1 Update SmbShare.ArgumentCompleters.ps1 (#54) May 2, 2016
Storage.ArgumentCompleters.ps1 Remove attribute based registration Jul 10, 2015
TabExpansionPlusPlus.ArgumentCompleters.ps1 Finish module rename for PSGallery Nov 15, 2015
TabExpansionPlusPlus.psd1 Update module version Jun 21, 2016
TabExpansionPlusPlus.psm1 Support to display existing completionPrivateData (#72) Jun 20, 2016
Wdac.ArgumentCompleters.ps1 Use static registration to speed up module load Jul 13, 2015
WindowsExe.ArgumentCompleters.ps1 Merge branch 'master' into DropScanningRegistration Jul 10, 2015
WindowsExe.Messages.psd1 Add native command tree support for argument completion Feb 15, 2013
about_TabExpansionPlusPlus.help.txt Update to ISE code snippets (#73) Jun 20, 2016

README.md

TabExpansionPlusPlus

Important note: The module was formerly known as TabExpansion++. It is now TabExpansionPlusPlus.

Starting with PowerShell version 3.0, there is excellent support for tab expansion and Intellisense, but it is missing some useful features. This module addresses some of those shortcomings.

TabExpansionPlusPlus adds support for the following:

  • Easily add custom argument completion.
  • Complete attribute argument names, e.g. [CmdletBinding(Def -or- [Parameter(
  • Exclude hidden files from results.
  • Easily set options like 'IgnoreHiddenShares'.

In addition to making it simple to add custom argument completion, TabExpansionPlusPlus provides many useful custom argument completers "out of box" that can also serve as good examples of how to add your own.

Usage

Assuming you've installed the module somewhere in your module path, just import the module in your profile, e.g.:

Import-Module TabExpansionPlusPlus

When you import the TabExpansionPlusPlus module, all of the default argument completer functions will be available to you. However, you can create your own argument completer functions to auto-complete parameter values for your own functions.

Installing

If you have PowerShell V5, or have installed PowerShellGet for V3, you can install right away with:

Install-Module TabExpansionPlusPlus

Alternatively, you can install in your personal modules folder (e.g. ~\Documents\WindowsPowerShell\Modules), iwith:

iex (new-object System.Net.WebClient).DownloadString('https://raw.github.com/lzybkr/TabExpansionPlusPlus/master/Install.ps1')

If you want to install elsewhere, you can download Install.ps1 (using the URL above) and run it, passing in the directory you want to install.

Custom Argument Completers

Create Argument Completer Functions

To create your own, custom argument completer functions inside a custom module, follow this process:

  1. Include a new script file with your module called <ModuleName>.ArgumentCompleters.ps1
  2. Declare a function inside the script file. This function will be invoked every time that auto-completion is invoked.
  3. The param() block must accept the following parameters. You do not have to specify the input parameter values, however.
    • $commandName = The name of the PowerShell command that the auto-completer applies to.
    • $parameterName = The name of the PowerShell command parameter that will be auto-completed.
    • $wordToComplete = The partial text that will be auto-completed.
    • $commandAst
    • $fakeBoundParameter
  4. The function must return one or more instances of System.Management.Automation.CompletionResult. The New-CompletionResult command aids with constructing these objects.
function VerbCompletion {
    param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)

    Get-Verb "$wordToComplete*" |
        ForEach-Object {
            New-CompletionResult -CompletionText $_.Verb -ToolTip ("Group: " + $_.Group)
        }   
}

Import Your Argument Completer

After you have created a custom argument completer function, the Register-ArgumentCompleter command must be used to register your custom argument completer function with the appropriate PowerShell commands/parameters.

The following parameters should be specified in the call to Register-ArgumentCompleter:

  • -Command = An array of PowerShell command names that share a parameter. You can pass in a static array of command values or dynamically obtain them using Get-Command (PowerShell Core) or Get-CommandWithParameter (TabExpansionPlusPlus)
  • -Parameter = The name of the parameter that the auto-completer function will auto-complete values for.
  • -Description = A description of the registered argument completer.
  • -ScriptBlock = The PowerShell ScriptBlock that will be executed when the argument completer is invoked.
Register-ArgumentCompleter -CommandName Get-Verb -Parameter Verb -ScriptBlock $function:VerbCompletion -Description 'This argument completer handles the -Verb parameter of the Get-Verb command.'

Note that PowerShell V5 has a cmdlet named Register-ArgumentCompleter. This cmdlet is very similar to the function in TabExpansionPlusPlus with two key differences: the V5 cmdlet does not have a -Description parameter, and there is no way to list the registered completers if you use the V5 cmdlet.

Module authors that target V3 and beyond that provide argument completion for their module that works with TabExpansionPlusPlus and/or PowerShell V5 should use the following pattern:

if (Get-Command Register-ArgumentCompleter -ea Ignore)
{
    Register-ArgumentCompleter -Command $Command -Parameter $Parameter -ScriptBlock { ... }
}

This way, there is no need to override the TabExpansion or TabExpansion2 functions, just suggest that users of your module use PowerShell V5 or TabExpansionPlusPlus.

Testing Your Argument Completer

After you have created your custom argument completer function, and registered it, you should test auto-completion to ensure that the function is working as expected. The TabExpansionPlusPlus module includes a command to aid in this testing called Test-ArgumentCompleter.

At a minimum, you must specify the following parameters to Test-ArgumentCompleter:

  • -CommandName = The name of the command whose argument completer will be tested.
  • -ParameterName = The name of the parameter, on the command specified in the -CommandName parameter, whose argument completer will be tested.
### Test the argument completer with no input
Test-ArgumentCompleter -CommandName Get-Verb -ParameterName Verb

### Test the argument completer with input
Test-ArgumentCompleter -CommandName Get-Verb -ParameterName Verb

Issues / Feedback

For any issues or feedback related to this module, please register for GitHub, and post your inquiry to this project's issue tracker.