{"id":12331,"date":"2011-10-21T00:01:00","date_gmt":"2011-10-21T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2011\/10\/21\/create-a-really-cool-powershell-ise-profile\/"},"modified":"2023-05-15T15:19:29","modified_gmt":"2023-05-15T22:19:29","slug":"create-a-really-cool-powershell-ise-profile","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/create-a-really-cool-powershell-ise-profile\/","title":{"rendered":"Create a Really Cool PowerShell ISE Profile"},"content":{"rendered":"<p><strong>Summary:<\/strong> Learn how to create a powerful Windows PowerShell ISE profile by running a single script.<\/p>\n<p>&nbsp;<\/p>\n<p>Microsoft Scripting Guy Ed Wilson here. One of the problems with writing a daily blog is that after a while, you end with a huge collection of articles and scripts. When I got a new laptop, and immediately left the country, I was really happy that I could access the Hey, Scripting Guy! Blog, and copy scripts so I could customize my Windows PowerShell ISE. Then I realized I had a problem: everything was cumulative, which meant that I spent hours and hours copying scripts, running scripts, and checking through dozens of Hey, Scripting Guy! Blog posts (many of which referenced other Hey, Scripting Guy! Blog posts). You get the idea.<\/p>\n<p>Luckily, I was able to begin with the Weekend Scripter article, <a href=\"https:\/\/devblogs.microsoft.com\/scripting\/weekend-scripter-clean-up-your-powershell-ise-profile-by-using-a-module\/\">Clean Up Your PowerShell ISE Profile by Using a Module<\/a>. But I wrote that article nearly a year ago, so there was a huge amount of new material to work through. In the end, I decided to do a \u201cnew release\u201d of my profile and associated modules.<\/p>\n<p>I have uploaded my current Windows PowerShell ISE profile to the <del>Scripting Guys Script Repository<\/del>. The profile script is very simple, and it is shown here:<\/p>\n<p style=\"padding-left: 30px;\">import-module PowerShellISEModule<\/p>\n<p style=\"padding-left: 30px;\">import-module MenuModule<\/p>\n<p style=\"padding-left: 30px;\">import-module SnippetModule<\/p>\n<p style=\"padding-left: 30px;\">import-module copymodule<\/p>\n<p style=\"padding-left: 30px;\">BackUp-Profile<\/p>\n<p style=\"padding-left: 30px;\">Add-MenuItems<\/p>\n<p style=\"padding-left: 30px;\">New-ModuleDrives<\/p>\n<p>The reason the code is so short is that everything is in the four accompanying modules. I will begin with the <b>PowerShellISEModule<\/b>. This is the main module, and it contains a number of really cool functions and a few aliases for those functions. The aliases and associated functions are discoverable by using the <b>Get-Command<\/b> cmdlet. Here is the code I use:<\/p>\n<p style=\"padding-left: 30px;\">Get-Command -Module powershellisemodule | sort commandtype<\/p>\n<p>The command and associated output are shown in the following figure.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/0842.hsg-10-21-11-1.png\"><img decoding=\"async\" title=\"Image of command and associated output\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/0842.hsg-10-21-11-1.png\" alt=\"Image of command and associated output\" \/><\/a><\/p>\n<p>The functions from the <a href=\"https:\/\/www.powershellgallery.com\/packages\/PowerShellISEModule\"><b>PowerISEModule<\/b><\/a> are shown here. I have included links to the Hey, Scripting Guy! Blog post where I discussed each of these functions:<\/p>\n<p style=\"padding-left: 30px;\"><a href=\"https:\/\/devblogs.microsoft.com\/scripting\/hey-scripting-guy-january-20-2010\">New-ModuleDrives\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/a><\/p>\n<p style=\"padding-left: 30px;\"><a href=\"https:\/\/devblogs.microsoft.com\/scripting\/create-a-transcript-of-commands-from-the-windows-powershell-ise\/\">Start-iseTranscript\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/a><\/p>\n<p style=\"padding-left: 30px;\"><a href=\"https:\/\/devblogs.microsoft.com\/scripting\/modify-the-powershell-ise-to-remove-aliases-from-scripts\/\">Remove-AliasFromScript\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/a><\/p>\n<p style=\"padding-left: 30px;\"><a href=\"https:\/\/devblogs.microsoft.com\/scripting\/how-to-create-a-customizable-profile-for-the-powershell-ise\">Set-Profile\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/a><\/p>\n<p style=\"padding-left: 30px;\"><a href=\"https:\/\/devblogs.microsoft.com\/scripting\/automatically-add-comment-based-help-to-your-powershell-scripts\">Add-Help\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/a><\/p>\n<p style=\"padding-left: 30px;\"><a href=\"https:\/\/devblogs.microsoft.com\/scripting\/modify-the-powershell-ise-to-automatically-add-a-script-header\">Add-HeaderToScript\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/a><\/p>\n<p style=\"padding-left: 30px;\"><a href=\"https:\/\/devblogs.microsoft.com\/scripting\/weekend-scripter-clean-up-your-powershell-ise-profile-by-using-a-module\">backUp-Profile\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/a><\/p>\n<p style=\"padding-left: 30px;\"><a href=\"https:\/\/devblogs.microsoft.com\/scripting\/create-a-transcript-of-commands-from-the-windows-powershell-ise\/\">Get-logNameFromDate\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/a><\/p>\n<p style=\"padding-left: 30px;\"><a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2010\/01\/20\/hey-scripting-guy-january-20-2010.aspx\">Get-FileSystemDrives\u00a0\u00a0 <\/a><\/p>\n<p>&nbsp;<\/p>\n<p>The <b>MenuModule<\/b> is new, but it incorporates all of the elements from my articles that talk about adding menu items to the Windows PowerShell ISE. The four functions contained in this module are shown here:<\/p>\n<p style=\"padding-left: 30px;\">Add-MenuItems<\/p>\n<p style=\"padding-left: 30px;\">Get-Fonts<\/p>\n<p style=\"padding-left: 30px;\">Get-PsIseColorValues<\/p>\n<p style=\"padding-left: 30px;\">Set-PsISE<\/p>\n<p>I made a few changes to the Add<b>-MenuItems<\/b> function because I moved the ISE preference scripts into functions in order to consolidate the functionality and to make it easier to customize the ISE. Now instead of having numerous dependencies on various scripts that may reside in different locations, I put everything into a module.<\/p>\n<p>The <b>SnippetModule<\/b> is also new. I modified the <b>Export-ModuleMember<\/b> command to export only one function. When using the <b>Get-Command<\/b> cmdlet, only one function appears. That function is the <b>Get-CodeSnippetV2<\/b> function. I wrote a series of articles that talk about adding code snippet functionality to the Windows PowerShell ISE.<\/p>\n<p>However, there are many other functions in the <b>SnippetModule<\/b>:<\/p>\n<p style=\"padding-left: 30px;\">New-Sniptype<\/p>\n<p style=\"padding-left: 30px;\">Remove-sniptype<\/p>\n<p style=\"padding-left: 30px;\">copy-codeSnippetsFromInterNet<\/p>\n<p style=\"padding-left: 30px;\">Test-IsAdministrator<\/p>\n<p style=\"padding-left: 30px;\">Register-CodeSnippets<\/p>\n<p>The preceding functions are used to install the code snippet functionality into the Windows PowerShell ISE. If you need to do this, modify the <b>Export-ModuleMember<\/b> command at the bottom of the <b>snippetModule<\/b>. This command is shown here:<\/p>\n<p style=\"padding-left: 30px;\">Export-ModuleMember -Function Get-CodeSnippetV2, Register-CodeSnippets -Variable sniphome<\/p>\n<p>After you have installed the code snippets, there is no reason to include the <b>Register-CodeSnippets<\/b> function into your daily Windows PowerShell ISE profile. I highly recommend that you use the <i>\u2013path<\/i> parameter and specify the path to the snip.zip file when installing the code snippets feature. When I was testing the installation from the Internet feature, it worked once out of four attempts. The command to register the code snippets using the path feature would appear something like this (assuming I had copied the snip.zip file to the c:\\fso folder):<\/p>\n<p style=\"padding-left: 30px;\">Register-CodeSnippets \u2013path c:\\fso\\snip.zip<\/p>\n<p>I initially wrote the <a href=\"https:\/\/devblogs.microsoft.com\/scripting\/hey-scripting-guy-january-20-2010\">Copy-Modules.ps1<\/a> script for my <a href=\"http:\/\/www.amazon.com\/Windows-PowerShell-2-0-Best-Practices\/dp\/0735626464\/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1255959455&amp;sr=8-1\">Windows PowerShell 2.0 Best Practices book<\/a>, and I have been using it on a regular basis ever since. Well, today I decided to add it to a module itself. The reason is I wanted to make it easy to bring into my Windows PowerShell ISE profile. I put all of the functions into the <b>CopyModule<\/b> module, and only export the <b>Copy-Modules<\/b> function. The <b>Copy-Modules<\/b> function takes a single parameter that is the folder that contains all of the <i>psm1 <\/i>files to import. This command is shown here:<\/p>\n<p style=\"padding-left: 30px;\">Copy-Modules \u2013path c:\\fso<\/p>\n<p>To install this ISE module release, use the Copy-ISEProfile.ps1 script that is included in the ISE_Modules.zip file that you can download from the <del>Scripting Guys Script Repository<\/del>.<\/p>\n<p>The Copy-ISEProfile.ps1 script is shown here:<\/p>\n<p style=\"padding-left: 30px;\">$path = &#8220;C:\\fso&#8221;<\/p>\n<p style=\"padding-left: 30px;\">If(!(Test-Path $profile))<\/p>\n<p style=\"padding-left: 30px;\">\u00a0 {new-item -Path $profile -ItemType file -force}<\/p>\n<p style=\"padding-left: 30px;\">Import-Module -Name (Join-Path -Path $path -ChildPath copymodule.psm1)<\/p>\n<p style=\"padding-left: 30px;\">Copy-Modules -path $path<\/p>\n<p style=\"padding-left: 30px;\">psedit $profile<\/p>\n<p>When you run the Copy-ISEProfile.ps1 script, provide the path to where the ISE modules are extracted. At the end of running the <b>Copy-ISEProfile<\/b> script, it will open the ISE profile in a new tab. Paste the ISE module commands to the profile. These commands appear here, but are on the Scripting Guys Script Repository as well:<\/p>\n<p style=\"padding-left: 30px;\">import-module PowerShellISEModule<\/p>\n<p style=\"padding-left: 30px;\">import-module MenuModule<\/p>\n<p style=\"padding-left: 30px;\">import-module SnippetModule<\/p>\n<p style=\"padding-left: 30px;\">import-module copymodule<\/p>\n<p style=\"padding-left: 30px;\">BackUp-Profile<\/p>\n<p style=\"padding-left: 30px;\">Add-MenuItems<\/p>\n<p style=\"padding-left: 30px;\">New-ModuleDrives<\/p>\n<p style=\"padding-left: 30px;\">\n<p>Well, that is about it for now. Join me tomorrow for more Windows PowerShell goodness.<\/p>\n<p>I invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\" rel=\"noopener\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\" rel=\"noopener\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\" rel=\"noopener\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p><b>Ed Wilson, Microsoft Scripting Guy<\/b><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Learn how to create a powerful Windows PowerShell ISE profile by running a single script. &nbsp; Microsoft Scripting Guy Ed Wilson here. One of the problems with writing a daily blog is that after a while, you end with a huge collection of articles and scripts. When I got a new laptop, and immediately [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[144,3,4,45,100],"class_list":["post-12331","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-profiles","tag-scripting-guy","tag-scripting-techniques","tag-windows-powershell","tag-windows-powershell-ise"],"acf":[],"blog_post_summary":"<p>Summary: Learn how to create a powerful Windows PowerShell ISE profile by running a single script. &nbsp; Microsoft Scripting Guy Ed Wilson here. One of the problems with writing a daily blog is that after a while, you end with a huge collection of articles and scripts. When I got a new laptop, and immediately [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/12331","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=12331"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/12331\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=12331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=12331"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=12331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}