February 2019
Intermediate to advanced
626 pages
15h 51m
English
While it is possible to register argument-completers, PowerShell does not provide a way of listing them. This is somewhat frustrating as it makes exploration and finding examples more difficult.
The following script makes extensive use of reflection in .NET to explore classes that are not made publicly available, eventually getting to a property that holds the argument-completers:
$localPipeline = [PowerShell].Assembly.GetType('System.Management.Automation.Runspaces.LocalPipeline')$getExecutionContextFromTLS = $localPipeline.GetMethod( 'GetExecutionContextFromTLS', [System.Reflection.BindingFlags]'Static, NonPublic')$internalExecutionContext = $getExecutionContextFromTLS.Invoke( $null, [System.Reflection.BindingFlags]'Static, ...Read now
Unlock full access