You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Provide a way to exclude cmdlets from some modules from completions in a concrete powershell session #16747
As a user I want to configure my powershell profile to exclude completion from certain modules that I'm not using on a given context. For example, as a developer when I'm on a powershell session and type Remove-I for (remove-item) the first result I get on autocompletion is Remove-InitiatorId.
In many scenarios like these, some commands that won't ever be used in this context lead to a poor experience where you need to either type more characters to disambiguate or tab through.
It's great that by default you can get commands from all installed modules for discoverability, but with the growing number of modules it becomes painful to use on a regular session.
To provide an analogy, this is similar to importing all namespaces by default on C#, each type is readily available, but searching through the types becomes much more problematic because they are way more irrelevant types in scope.
Ideally this would be either an allow list or a block list (possibly an allow list), where you can set your preferences for the session via a cmd-let to filter completions to the modules you've defined.
That will make only commands in those modules to be considered for completions and you can put this on your $Profile so that it happens every time you create a new session.
I would like to ask a similar question.
I have developed a multi-process powershell automatic management tool [kasini3000].
I want to know how to get a powershell with the least functions, the smallest memory footprint, and the smallest powershell without loading most .net dlls. Only powershell engine,
how should I do it?
You can (mostly) do this today. If you set $PSModuleAutoLoadingPreference = "None" PowerShell won't find commands from modules that haven't been imported so instead of running Set-CommandCompletion Microsoft.PowerShell.Utility, Microsoft.PowerShell.Management to limit completions to commands from those modules you instead use Import-Module Microsoft.PowerShell.Utility, Microsoft.PowerShell.Management to explicitly import the modules you want to use in your session.
Well, this is awkward. I actually have 2 pending PRs to fix this particular issue. One for adding the option to Get-Command: #18955 and another to add commands to manage various completion options: #19518
I know I was initially against the idea, but I changed my mind after installing some modules that added literally thousands of commands to my command completion, many of which I have no use for when I'm in the shell. In an editor it can also be nice to filter out commands from for example VMware if you are working on a Hyper-V script and vice versa without disabling autoloading of modules.
microsoft-github-policy-service commented on Aug 3, 2023
Activity
jhoneill commentedon Jan 14, 2022
At the very least, prioritizing commands from loaded modules over those in available modules would help.
kasini3000 commentedon Jan 14, 2022
I would like to ask a similar question.
I have developed a multi-process powershell automatic management tool [kasini3000].
I want to know how to get a powershell with the least functions, the smallest memory footprint, and the smallest powershell without loading most .net dlls. Only powershell engine,
how should I do it?
MartinGC94 commentedon Sep 19, 2022
You can (mostly) do this today. If you set
$PSModuleAutoLoadingPreference = "None"PowerShell won't find commands from modules that haven't been imported so instead of runningSet-CommandCompletion Microsoft.PowerShell.Utility, Microsoft.PowerShell.Managementto limit completions to commands from those modules you instead useImport-Module Microsoft.PowerShell.Utility, Microsoft.PowerShell.Managementto explicitly import the modules you want to use in your session.theJasonHelmick commentedon Aug 2, 2023
Thank you for the feature suggestion! The WG reviewed this and feels that by having an allow list, could create even more confusion. The above suggestion from MartinGC94 to disable autoloading of the modules would be a benefit -- also note that you can create a custom expansion to filter the results. There are multiple examples on the PSGallery that may be of interest. https://teams.microsoft.com/l/message/19:meeting_OTE4MDhkYzAtMmM0Ni00MjRjLWEwMjEtNTJhOTM1OTZhMTFi@thread.v2/1691007155506?context=%7B%22contextType%22%3A%22chat%22%7D
MartinGC94 commentedon Aug 2, 2023
Well, this is awkward. I actually have 2 pending PRs to fix this particular issue. One for adding the option to
Get-Command: #18955 and another to add commands to manage various completion options: #19518I know I was initially against the idea, but I changed my mind after installing some modules that added literally thousands of commands to my command completion, many of which I have no use for when I'm in the shell. In an editor it can also be nice to filter out commands from for example VMware if you are working on a Hyper-V script and vice versa without disabling autoloading of modules.
microsoft-github-policy-service commentedon Aug 3, 2023
This issue has been marked as declined and has not had any activity for 1 day. It has been closed for housekeeping purposes.