For VS Code, I have re-created the Advanced Function snippet found in the PowerShell ISE. This snippet allows one to readily have a rather complete Advanced Function template.
What are the advantages of an Advanced Function? Common Attributes and better control logic (BEGIN, PROCESS, END). It also includes templating for help and metadata comments.
It is available on Github: VSCodePoShSnippet
In the PowerShell ISE, one would press [Ctrl] + J to bring up the snippets, but this is done with [Ctrl]+[Space] in VS Code.
Since copy/paste or overwrite your user snippet with this JSON file. Your user snippets are accessible via “File” > “Preferences” > “User Snippets” from within VS Code, or in “\AppData\Roaming\Code\User\snippets”.
If you’re unfamiliar with VS Code, I had a really quick video on installing it and demonstrating how to use it with PowerShell code in my previous post.
If you would like to support my continued efforts, consider getting a copy of Learn Windows PowerShell in a Month of Lunches or another title through Amazon
.
One thought on “VS Code PowerShell Advanced Function Snippet”