PowerShellEditorServices
PowerShellEditorServices copied to clipboard
Add blocklist/inclusion list for editor commands
Eventually there is going to be a need to ignore certain Commands or Modules when PSES Registers Commands.
Here are the ideas I have had.
- Block all Registering from outside of Profile
- Block all Registering from Blacklisted Modules.
- Only Allow Registering from Whitelisted Modules
- Only Allow Registering Whitelisted Commands
You can currently do something like the following:
# Microsoft.VSCode_profile.ps1
Import-Module Blah1
Import-Module Blah2
Import-Module Blah3
Import-Module Blah4
Import-Module Blah5
# Do All The Things Here
Unregister-EditorCommand -Name Command1FromBlah1
Unregister-EditorCommand -Name Command2FromBlah1
Unregister-EditorCommand -Name Command1FromBlah2
Unregister-EditorCommand -Name Command2FromBlah2
Unregister-EditorCommand -Name Command3FromBlah3
Unregister-EditorCommand -Name Command1FromBlah4
Unregister-EditorCommand -Name Command1FromBlah5
Unregister-EditorCommand -Name Command2FromBlah5
Unregister-EditorCommand -Name Command3FromBlah5
However, this would quickly become a headache and hard to maintain if a Module is regularly adding commands etc.
Yep, I've thought about this too. I think it'd be easier to blacklist specific modules and commands than having to maintain a whitelist, though I suppose a whitelist makes sense if you know you only ever want to use one or two modules.
Yeah, I think a blacklist that also allows for entire module is for sure needed. The others I wanted to mention to see what others might think.