I do a lot of Winforms and WPF GUI design in Visual Studio and then further perfect my form in Visual Studio Code. (I'm using PowerShell Pro Tools from Ironman Studios)
In VSCode, it's extremely easy to add and use snippets for PowerShell, especially with the Snippet Generator and Snippets Viewer addons installed:
I'm trying to replicate this somehow in Visual Studio Community 2022. I've defined a PowerShell snippet with the following code:
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>GUI Enable Visual Styles</Title>
<Description>Enable Visual Styles</Description>
<Shortcut>enablevs</Shortcut>
</Header>
<Snippet>
<Code Language="PowerShell">
<![CDATA[
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
Add-Type -AssemblyName PresentationCore,PresentationFramework
[System.Windows.Forms.Application]::EnableVisualStyles()
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
And I saved the file here: C:\Users\Username\Documents\Visual Studio 2022\Code Snippets\PowerShell\My Code Snippets\EnableVisualStyles.snippet
Then, with a PowerShell file open, I right click and choose Snippet > Insert Snippet:
But I get an empty input box shown here:
No matter what I type in that box, for example the shortcut name of the snippet, I get no suggestions and if I press enter I get the following error:
Am I missing something? Is there any way to access PowerShell snippets in.ps1 files?
Is there some kind of extension on the marketplace that will add extended support for snippets?
This is pretty crucial to me, as I depend heavily on my snippets library when developing.
Any help at all would be extremely welcomed.



