Recently I discovered Glen Scales post “EWS Snippets for PowerGui” Although PowerGUI now works with version 3 of PowerShell, I am still using the PowerShell ISE for script development.
So, I wrote a script to convert PowerGUI snippets to PowerShell ISE snippets. Both PowerGUI and PowerShell ISE snippets are written in XML. Sadly, I am not much into XML, so I Bing’d “PowerShell Create XML” and found Creating XML Documents from PowerShell. That got me started on my script, and most importantly, led me to the MSDN documentation for the XmlWriter Methods.
I have tested the script on the EWS Snippets for PowerGui and the JAMS Job Scheduler snippets and it seems to work well.
All of the parameters are optional. If you do not specify the optional “SnippetPath” parameter, the script defaults to using the snippet path of <User>\<MyDocuments>\WindowsPowerShell\snippets.
The script accepts the optional switch parameter “KeepPowerGUI” which, if set, will keep the PowerGUI version of the snippets. Another optional switch parameter, “Append” will append the specified “SnippetPath” to the snippet path of <User>\<MyDocuments>\WindowsPowerShell\snippets.
The script is published on http://gallery.technet.microsoft.com/Convert-PowerGUI-Snippets-d05c17b3 or you can copy it from below.
001
002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095 096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
<#
.SYNOPSIS ConvertFrom-PowerGUI.ps1 – Modifies PowerGUI Snippets to work with the PowerShell ISE. .DESCRIPTION This script modifies PowerGUI Snippets to work with the PowerShell ISE. .EXAMPLE .\ConvertFrom-PowerGUI.ps1 Description Modifies existing PowerGUI snippets to work with the PowerShell ISE. .EXAMPLE .\ConvertFrom-PowerGUI.ps1 -KeepPowerGUI Description Modifies existing PowerGUI snippets to work with the PowerShell ISE, while preserving the PowerGUI versions. .EXAMPLE .\ConvertFrom-PowerGUI.ps1 -SnippetPath C:\Scripts\Snippets Description Modifies existing PowerGUI snippets in the path C:\Scripts\Snippets to work with the PowerShell ISE. .EXAMPLE .\ConvertFrom-PowerGUI.ps1 -SnippetPath “TestSnippets” -Append Description Modifies existing PowerGUI snippets in the path <User>\<MyDocuments>\WindowsPowerShell\snippets\TestSnippets to work with the PowerShell ISE. .NOTES Created: 05/17/2013 Karl Mitschke .PARAMATER KeepPowerGUI When set, keeps the PowerGUI snippets. .PARAMATER SnippetPath If specified, converts snippets in the SnippetPath. If not specified, will use the default snippet path of <User>\<MyDocuments>\WindowsPowerShell\snippets. .PARAMATER Append If specified, appends the specified SnippetPath to the default snippet path of <User>\<MyDocuments>\WindowsPowerShell\snippets. #> [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact=‘Medium’)] begin{ |