PowerShell Logo Small

Import-IseSnippet



This is the built-in help made by Microsoft for the command 'Import-IseSnippet', in PowerShell version 3 - as retrieved from Windows version 'Microsoft Windows Server 2012 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Imports ISE snippets into the current session

SYNTAX


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



Search powershellhelp.space

DESCRIPTION


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 ISEEdit menu, click Start Snippets or press . The Get-IseSnippet cmdlet,
which gets user-created snippets in the local snippets directory, does not get imported snippets.. The Get-IseSnippet cmdlet, which gets
user-created snippets in the local snippets directory, does not get imported snippets.


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 be imported, the snippets 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.


This cmdlet is introduced in Windows PowerShell 3.0.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/?LinkID=242050
Get-IseSnippet
New-IseSnippet

REMARKS

<

Examples


Example 1: Import snippets from a directory

PS C:\> Import-IseSnippet -Path \\Server01\Public\Snippets -Recurse



This command imports the snippets from the \\Server01\Public\Snippets directory into the current session. It uses the Recurse parameter to get
snippets from all subdirectories of the Snippets directory.




Example 2: Import snippets from a module

PS C:\> Import-IseSnippet -Module SnippetModule -ListAvailable



This command imports the snippets from the SnippetModule module. The command uses the ListAvailable parameter to import the snippets even if
the SnippetModule module is not imported into the user's session when the command runs.




Example 3: Find snippets in modules

PS C:\> ($env:PSModulePath).split(";") | foreach {dir $_\*\Snippets\*.Snippets.ps1xml -ErrorAction SilentlyContinue} | foreach {$_.fullname}



This command gets snippets in all installed modules in the PSModulePath environment variable.




Example 4: Import all module snippets

PS C:\> ($env:PSModulePath).split(";") | foreach {dir $_\*\Snippets\*.Snippets.ps1xml -ErrorAction SilentlyContinue} | foreach
{$psise.CurrentPowerShellTab.Snippets.Load($_)}



This command imports all snippets from all installed modules into the current session. Typically, you don't need to run a command like this
because modules that have snippets will use the Import-IseSnippet cmdlet to import them for you when the module is imported.




Example 5: Copy all module snippets

PS C:\> ($env:PSModulePath).split(";") | foreach {dir $_\*\Snippets\*.Snippets.ps1xml -ErrorAction SilentlyContinue} | Copy-Item -Destination
$home\Documents\WindowsPowerShell\Snippets



This command copies the snippet files from all installed modules into the Snippets directory of the current user. Unlike imported snippets,
which affect only the current session, copied snippets are available in every Windows PowerShell ISE session.