{"id":74861,"date":"2015-11-13T00:01:00","date_gmt":"2015-11-13T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2015\/11\/13\/set-powershell-ise-to-default-values\/"},"modified":"2019-02-18T09:34:33","modified_gmt":"2019-02-18T16:34:33","slug":"set-powershell-ise-to-default-values","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/set-powershell-ise-to-default-values\/","title":{"rendered":"Set PowerShell ISE to Default Values"},"content":{"rendered":"<p><b style=\"font-size:12px\">Summary<\/b><span style=\"font-size:12px\">: Ed Wilson, Microsoft Scripting Guy, talks about resetting the Windows PowerShell ISE settings to the defaults.<\/span><\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. One of the great things about Windows PowerShell is that it is highly configurable. Not only the things that I can configure, but Windows PowerShell itself. The behaviors in the Windows PowerShell console and the Windows PowerShell ISE can be quickly changed. One of the best ways to do this is to use a Windows PowerShell profile. I like to create specific profiles for certain environments instead of one big monolithic profile. In fact, I like to use modules to encapsulate certain pieces of functionality.<\/p>\n<p>But with all that tweaking, changing, and configuring, it is easy to get things really messed up. Simply exiting the program and reloading it does not always reset things. In fact, rebooting the computer does not always reset stuff. One of my rules has always been that when I write something that makes a change, I like to also write something that will undo that change. It is a rather hard-fought rule that I learned after having to reinstall Windows a few times.<\/p>\n<p>Anyway, since I have been talking about making changes to the Windows PowerShell ISE, I thought I would share how to reset the defaults.<\/p>\n<h2>Not all defaults are default&hellip;<\/h2>\n<p>The first thing to learn is that there are many levels of defaults in the Windows PowerShell ISE. For example, there are console pane token colors, script pane token colors, and XML token colors.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-11-13-15-01.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-11-13-15-01.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>I can set the token colors for the Windows PowerShell ISE script pane by using the <b>TokenColors<\/b> object. Each token is an assignment value. In the previous image, I set the comment color to red. It will affect only the script pane, not the console pane. To reset the default token colors used in the script pane, I use <b>RestoreDefaultTokenColors<\/b> method. I found this method by examining the <b>Options<\/b> object:<\/p>\n<p style=\"margin-left:30px\">PS C:\\&gt; $psISE.Options | gm -MemberType Method<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp; TypeName: Microsoft.PowerShell.Host.ISE.ISEOptions<\/p>\n<p style=\"margin-left:30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MemberType Definition&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n<p style=\"margin-left:30px\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8212;&#8212;&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&#8212;&#8212;&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n<p style=\"margin-left:30px\">Equals&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; bool Equals(System.Object obj)&nbsp;&nbsp;&nbsp; &nbsp;<\/p>\n<p style=\"margin-left:30px\">GetHashCode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; int GetHashCode()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n<p style=\"margin-left:30px\">GetType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; type GetType()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n<p style=\"margin-left:30px\">RestoreDefaultConsoleTokenColors Method&nbsp;&nbsp;&nbsp;&nbsp; void RestoreDefaultConsoleTokenC&#8230;<\/p>\n<p style=\"margin-left:30px\">RestoreDefaults&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; void RestoreDefaults()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n<p style=\"margin-left:30px\">RestoreDefaultTokenColors&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; void RestoreDefaultTokenColors()&nbsp;&nbsp;<\/p>\n<p style=\"margin-left:30px\">RestoreDefaultXmlTokenColors&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; void RestoreDefaultXmlTokenColors()<\/p>\n<p style=\"margin-left:30px\">ToString&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;Method&nbsp;&nbsp;&nbsp;&nbsp; string ToString()&nbsp;&nbsp;<\/p>\n<p>When I use the <b>RestoreDefaultTokenColors<\/b> method, the comment in the script automatically returns to green. Here is that command:<\/p>\n<p style=\"margin-left:30px\">$psISE.Options.RestoreDefaultTokenColors()<\/p>\n<p>The command and the associated output are shown here:<\/p>\n<p><span style=\"font-size:12px\"><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-11-13-15-02.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-11-13-15-02.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><br \/><\/span><\/p>\n<p><span style=\"font-size:12px\">I can do the same thing for the Windows PowerShell ISE console. In the following image, I set the console comment token to red, and when I type a comment, it is red. Note that the comment in the script pane remains unaffected.<\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-11-13-15-03.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-11-13-15-03.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>To restore the console tokens, I use the <b>RestoreDefaultConsoleTokenColors<\/b> method:<\/p>\n<p style=\"margin-left:30px\">$psISE.Options.RestoreDefaultConsoleTokenColors()<\/p>\n<p>If I have made changes (say putting things into a presentation mode for a presentation that I want to do), and I would like to just restore everything to its default value, I can use the more generic <b>RestoreDefaults<\/b> method. This resets everything&mdash;font size, zoom level, even the &ldquo;never show this prompt again&rdquo; prompt values. The command is shown here:<\/p>\n<p style=\"margin-left:30px\">$psISE.Options.RestoreDefaults()<\/p>\n<p>As you can see in the following image, my fonts and zoom levels have reverted to default values:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-11-13-15-04.png\" target=\"_blank\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-11-13-15-04.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>To be honest, if you have customized your ISE in any way, you really don&rsquo;t want to use this more extreme method of resetting the defaults. In fact, all four reset default methods are pretty heavy handed, and it is much better to store your particular defaults, and then restore those defaults when needed, rather than the methods listed here. Of course, if things are totally hosed, this is a good way to get back to the beginning without reinstalling Windows!<\/p>\n<p>That is all there is to using the defaults.&nbsp; Join me tomorrow when I will talk about more cool stuff.<\/p>\n<p>I invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p><b>Ed Wilson, Microsoft Scripting Guy<\/b><span style=\"font-size:12px\">&nbsp;<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Ed Wilson, Microsoft Scripting Guy, talks about resetting the Windows PowerShell ISE settings to the defaults. Microsoft Scripting Guy, Ed Wilson, is here. One of the great things about Windows PowerShell is that it is highly configurable. Not only the things that I can configure, but Windows PowerShell itself. The behaviors in the Windows [&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":[553,3,45],"class_list":["post-74861","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-ise","tag-scripting-guy","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Ed Wilson, Microsoft Scripting Guy, talks about resetting the Windows PowerShell ISE settings to the defaults. Microsoft Scripting Guy, Ed Wilson, is here. One of the great things about Windows PowerShell is that it is highly configurable. Not only the things that I can configure, but Windows PowerShell itself. The behaviors in the Windows [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/74861","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=74861"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/74861\/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=74861"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=74861"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=74861"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}