CmdID

CmdID / PowerShell / Cmdlets / Import

Import-IseSnippet

Imports ISE snippets into the current session PowerShell reference

From the PowerShell reference 4 parameters

Opens CmdID with your command, read as PowerShell. It is read in your browser and sent nowhere.

What it does

from the PowerShell reference, CC BY 4.0

Imports ISE snippets into the current session The Import-IseSnippet cmdlet imports reusable text "snippets" from a module or a directory into the current session. The snippets are immediately available for use in Windows PowerShell ISE. This cmdlet works only in Windows PowerShell Integrated Scripting Environment (ISE). To view and use the imported snippets, from the Windows PowerShell ISE Edit menu, click Start Snippets or press <kbd>Ctrl</kbd>+<kbd>J</kbd>. Imported snippets are available only in the current session. To import the snippets into all Windows PowerShell ISE sessions, add an Import-IseSnippet command to your Windows PowerShell profile or copy the snippet files to your local snippets directory $HOME\Documents\WindowsPowerShell\Snippets. To import snippets, they must be properly formatted in the snippet XML for Windows PowerShell ISE snippets and saved in Snippet.ps1xml files. To create eligible snippets, use the New-IseSnippet cmdlet. New-IseSnippet creates a <SnippetTitle>.Snippets.ps1xml file in the $HOME\Documents\WindowsPowerShell\Snippets directory. You can move or copy the snippets to the Snippets directory of a Windows PowerShell module, or to any other directory. The Get-IseSnippet cmdlet, which gets user-created snippets in the local snippets directory, does not get imported snippets. This cmdlet was introduced in Windows PowerShell 3.0.

Import-IseSnippet [-Path] <String> [-Recurse] [<CommonParameters>]
Import-IseSnippet [-Recurse] -Module <String> [-ListAvailable] [<CommonParameters>]

Import snippets from a directory

Import-IseSnippet -Path \\Server01\Public\Snippets -RecurseIdentify

Import snippets from a module

Import-IseSnippet -Module SnippetModule -ListAvailableIdentify

Find snippets in modules

($Env:PSModulePath).Split(";") | ForEach-Object {dir $_\*\Snippets\*.Snippets.ps1xml -ErrorAction SilentlyContinue} | ForEach-Object {$_.FullName}Identify

Import all module snippets

($Env:PSModulePath).Split(";") | ForEach-Object {dir $_\*\Snippets\*.Snippets.ps1xml -ErrorAction SilentlyContinue} | ForEach-Object {$psISE.CurrentPowerShellTab.Snippets.Load($_)}Identify

Copy all module snippets

($Env:PSModulePath).Split(";") | ForEach-Object {dir $_\*\Snippets\*.Snippets.ps1xml -ErrorAction SilentlyContinue} | Copy-Item -Destination $HOME\Documents\WindowsPowerShell\SnippetsIdentify

Its page in the reference: Import-IseSnippet.

Parameters

4 in the PowerShell reference
-ListAvailableIndicates that this cmdlet gets snippets from modules that are installed on the computer, even if the modules are not imported into the current session. If this parameter is omitted, and the module that is specified by the Module parameter is not imported into the current session, the attempt to get the snippets from the module fails. This parameter is valid only when the Module parameter is used in the command.
-ModuleImports snippets from the specified module into the current session. Wildcard characters are not supported. This parameter imports snippets from Snippet.ps1xml files in the Snippets subdirectory in the module path, such as $HOME\Documents\WindowsPowerShell\Modules\<ModuleName>\Snippets. This parameter is designed to be used by module authors in a startup script, such as a script specified in the ScriptsToProcess key of a module manifest. Snippets in a module are not automatically imported with the module, but you can use an Import-IseSnippet command to import them.
-PathSpecifies the path to the snippets directory in which this cmdlet imports snippets.
-RecurseIndicates that this cmdlet imports snippets from all subdirectories of the value of the Path parameter.