{"id":16571,"date":"2010-11-08T00:01:00","date_gmt":"2010-11-08T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2010\/11\/08\/use-net-classes-to-configure-the-windows-powershell-console\/"},"modified":"2010-11-08T00:01:00","modified_gmt":"2010-11-08T00:01:00","slug":"use-net-classes-to-configure-the-windows-powershell-console","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/use-net-classes-to-configure-the-windows-powershell-console\/","title":{"rendered":"Use .NET Classes to Configure the Windows PowerShell Console"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p><b>Summary:<\/b> The Microsoft Scripting Guys show how to use .NET Framework classes to configure the Windows PowerShell console.<\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" height=\"34\" width=\"34\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" align=\"left\" alt=\"Hey, Scripting Guy! Question\" border=\"0\" title=\"Hey, Scripting Guy! Question\" \/>Hey, Scripting Guy! I am curious about how the .NET Framework classes work. I saw posts from a couple weeks ago, but I still have questions. For example, it seems that the <a href=\"http:\/\/technet.microsoft.com\/en-us\/scriptcenter\/powershell.aspx\">Windows PowerShell<\/a> console is basically an old fashioned DOS prompt. How would the .NET Framework apply to that?<\/p>\n<p>&#8212; TL<\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" height=\"34\" width=\"34\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" align=\"left\" alt=\"Hey, Scripting Guy! Answer\" border=\"0\" title=\"Hey, Scripting Guy! Answer\" \/>Hello TL, Microsoft Scripting Guy Ed Wilson here. It is humid and tepid outside. It is the kind of weather that reminds me of winter when I was growing up in <a href=\"http:\/\/en.wikipedia.org\/wiki\/Florida\">Florida<\/a>. It is, of course still considered fall in the South Eastern part of the United States; winter does not officially begin down here until December 22. So maybe the weather reminds me of fall when I was growing up in Florida. At any rate, all I need is the smell of Palm trees, Coconut oil, and salt spray and I will be back home. I have the windows open in my office, and three fans going &#8230; I refuse to turn on the air conditioner in November just on general principles! Maybe I will turn on some <a href=\"http:\/\/en.wikipedia.org\/wiki\/The_Beach_Boys\">Beach Boys<\/a> on my <a href=\"http:\/\/zune.net\/en-us\/products\/zunehd\/default.htm\">Zune HD<\/a> and just go with the flow. Now, if I only had some pink lemonade I would be all set. <\/p>\n<p>TL, there is a .NET Framework class named <b>Console<\/b> that resides in the <b>System<\/b> namespace. The <b><a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.console.aspx\">System.Console<\/a><\/b> .NET Framework class represents the input, output and error streams for console applications. The Windows PowerShell console is a console application. According to MSDN, all the members (properties, methods, and events) of the Console class are static. MSDN represents static members with a big red &#8220;s&#8221; as shown in the following figure.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6433.HSG-11-08-10-01.jpg\" border=\"0\" \/>&nbsp;<\/p>\n<p>The cool thing about static members is that they are very easy to discover in Windows PowerShell. To do this I use the <b>Get-Member<\/b> Windows PowerShell cmdlet. Because it is Windows PowerShell, I can format the output as I want by piping the output to additional format cmdlets. In the example shown here, I <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/topics\/winpsh\/manual\/pipe.mspx\">pipe<\/a><span style=\"text-decoration: underline\">line<\/span> the output to the <b>Format-Table<\/b> cmdlet and select only the name and definition properties. <\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt; [system.console] | Get-Member -Static -MemberType property | Format-Table nam<br \/>e, definition -AutoSize<\/p>\n<p>Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Definition<br \/>&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;-<br \/>BackgroundColor&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.ConsoleColor BackgroundColor {get;set;}<br \/>BufferHeight&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.Int32 BufferHeight {get;set;}<br \/>BufferWidth&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.Int32 BufferWidth {get;set;}<br \/>CapsLock&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.Boolean CapsLock {get;}<br \/>CursorLeft&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.Int32 CursorLeft {get;set;}<br \/>CursorSize&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.Int32 CursorSize {get;set;}<br \/>CursorTop&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.Int32 CursorTop {get;set;}<br \/>CursorVisible&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.Boolean CursorVisible {get;set;}<br \/>Error&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;static System.IO.TextWriter Error {get;}<br \/>ForegroundColor&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.ConsoleColor ForegroundColor {get;set;}<br \/>In&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.IO.TextReader In {get;}<br \/>InputEncoding&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.Text.Encoding InputEncoding {get;set;}<br \/>KeyAvailable&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.Boolean KeyAvailable {get;}<br \/>LargestWindowHeight&nbsp; static System.Int32 LargestWindowHeight {get;}<br \/>LargestWindowWidth&nbsp;&nbsp; static System.Int32 LargestWindowWidth {get;}<br \/>NumberLock&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.Boolean NumberLock {get;}<br \/>Out&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.IO.TextWriter Out {get;}<br \/>OutputEncoding&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.Text.Encoding OutputEncoding {get;set;}<br \/>Title&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.String Title {get;set;}<br \/>TreatControlCAsInput static System.Boolean TreatControlCAsInput {get;set;}<br \/>WindowHeight&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.Int32 WindowHeight {get;set;}<br \/>WindowLeft&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.Int32 WindowLeft {get;set;}<br \/>WindowTop&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.Int32 WindowTop {get;set;}<br \/>WindowWidth&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.Int32 WindowWidth {get;set;}<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/p>\n<p>The <b>System.Console<\/b> .NET Framework class also contains several static methods. The methods are shown here. <\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt; [system.console] | Get-Member -Static -MemberType method | Format-Table name,<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;definition -AutoSize<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;Definition<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;-<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">Beep&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.Void Beep(), static System.Void Beep(int frequen&#8230;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">Clear&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.Void Clear()<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">Equals&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static bool Equals(System.Object objA, System.Object objB)<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">MoveBufferArea&nbsp;&nbsp;&nbsp;&nbsp; static System.Void MoveBufferArea(int sourceLeft, int sourceTo&#8230;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">OpenStandardError&nbsp; static System.IO.Stream OpenStandardError(), static System.IO&#8230;.<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">OpenStandardInput&nbsp; static System.IO.Stream OpenStandardInput(), static System.IO&#8230;.<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">OpenStandardOutput static System.IO.Stream OpenStandardOutput(), static System.IO&#8230;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">Read&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static int Read()<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">ReadKey&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.ConsoleKeyInfo ReadKey(), static System.ConsoleK&#8230;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">ReadLine&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static string ReadLine()<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">ReferenceEquals&nbsp;&nbsp;&nbsp; static bool ReferenceEquals(System.Object objA, System.Object &#8230;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">ResetColor&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.Void ResetColor()<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">SetBufferSize&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.Void SetBufferSize(int width, int height)<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">SetCursorPosition&nbsp; static System.Void SetCursorPosition(int left, int top)<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">SetError&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.Void SetError(System.IO.TextWriter newError)<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">SetIn&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.Void SetIn(System.IO.TextReader newIn)<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">SetOut&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.Void SetOut(System.IO.TextWriter newOut)<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">SetWindowPosition&nbsp; static System.Void SetWindowPosition(int left, int top)<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">SetWindowSize&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.Void SetWindowSize(int width, int height)<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">Write&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.Void Write(string format, System.Object arg0), s&#8230;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">WriteLine&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static System.Void WriteLine(), static System.Void WriteLine(b&#8230;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>The <b>Console<\/b> class has several static properties and methods that let you discover current Windows PowerShell console settings. These include the <b>WindowHeight<\/b>, <b>WindowWidth<\/b>, <b>BackgroundColor<\/b>, <b>ForegroundColor<\/b>, and <b>Title<\/b> properties. The code to retrieve these settings is seen here.<\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt; [console]::WindowHeight<br \/>10<br \/>PS C:\\&gt; [console]::windowWidth<br \/>47<br \/>PS C:\\&gt; [console]::BackgroundColor<br \/>DarkGray<br \/>PS C:\\&gt; [console]::ForegroundColor<br \/>White<br \/>PS C:\\&gt; [console]::Title<br \/>scripting guys rock!<br \/>PS C:\\&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>These are seen in the following figure.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7128.HSG-11-08-10-02.jpg\" border=\"0\" \/>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>The properties are read\/write. Therefore I can assign new values to them to change the way the Windows PowerShell console is displayed. The code to do this is seen here.<\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt; [console]::WindowHeight = 14<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt; [console]::WindowWidth = 50<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt; [console]::BackgroundColor = &#8220;blue&#8221;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt; [console]::ForegroundColor = &#8220;yellow&#8221;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt; [console]::Title = &#8220;a new title&#8221;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>The changes occur immediately. As seen in following figure the background and foreground colors do not affect the whole Windows PowerShell console, only the line where the code has executed, and new lines that are created. You can force the changes to paint the whole console by using the <b>clear-host<\/b> command. <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/2806.HSG-11-08-10-03.jpg\" border=\"0\" \/>&nbsp;<\/p>\n<p>After you close the Windows PowerShell console, the changes revert to the values that are specified for the console itself. You can cause your customizations to be applied every time that the Windows PowerShell console is opened by adding the commands to your <a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/tags\/windows+powershell\/getting+started\/profiles\/\">Windows PowerShell console profile<\/a>. <\/p>\n<p>Instead of assigning the height and width value to the window size, you can use the <b>SetWindowSize<\/b> method instead. It accepts the width and the height parameters as parameters to the static method. This is seen here. <\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt; [console]::SetWindowSize(45,7)<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>When the command is run, the Windows PowerShell console will resize itself as seen in the following figure.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7888.HSG-11-08-10-04.jpg\" border=\"0\" \/>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>To discover what kind of enumeration values can be used for the Windows PowerShell console background colors and foreground colors, I use the <b>Get-EnumAndValues.ps1<\/b> script I developed for the <a href=\"http:\/\/blogs.technet.comhttps:\/\/devblogs.microsoft.com\/scripting\/hey-scripting-guy-weekend-scripter-enumerations-and-values\/\">Hey, Scripting Guy! Weekend Scripter: Enumerations and Values post<\/a> I wrote back during the summer. In fact, this particular function<b>, Get-EnumValues<\/b> is so useful; I have added it to my <a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/tags\/windows+powershell\/profiles\/\">Windows PowerShell Profile<\/a>. As seen in the following figure there are 16 colors defined for the <b>System.ConsoleColor<\/b> enumeration and the values range from 0 &#8211; 15. <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5126.HSG-11-08-10-05.jpg\" border=\"0\" \/>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>The cool thing about finding the enumeration names and values is that it makes it possible to display all the colors to see what would work best. Before playing around too much with the Windows PowerShell console colors, I like to know what the command is to reset the colors back to their default values. It is the <b>resetcolors<\/b> static method. Here is that command.<\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">[console]::ResetColor()<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>Here is the code that I used to display the 16 background colors. The % sign is an alias for the <b><a href=\"http:\/\/blogs.technet.com\/heyscriptingguy\/archive\/2009\/05\/05\/how-can-i-loop-through-collections-with-windows-powershell.aspx\">Foreach<\/a>-Object<\/b> Windows PowerShell cmdlet. <\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">0..15 | % { [console]::BackgroundColor = $_ ; &#8220;console color $_&#8221; ; sleep 1 }<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>When I run this command, the output seen in the following figure appears. The last line, that cannot be read because it is basically whited out is the <span style=\"font-family: courier new,courier\">[console]::ResetColor() <\/span>command.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6011.HSG-11-08-10-06.jpg\" border=\"0\" \/>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>To see how well font colors are displayed, I change the code to change foreground colors. The modified code is seen here.<\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">0..15 | % { [console]::ForegroundColor = $_ ; &#8220;console color $_&#8221; ; sleep 1 }<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>When I run this command, the output seen in the following figure appears.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/1033.HSG-11-08-10-07.jpg\" border=\"0\" \/>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>TL, that is all there is to using the <b>System.Console<\/b> .NET Framework class to configure the Windows PowerShell console. .NET Framework week will continue tomorrow when I will talk about how to work with static methods on .NET Framework classes. <\/p>\n<p>I invite you to follow me on <a target=\"_blank\" href=\"http:\/\/bit.ly\/scriptingguystwitter\">Twitter<\/a> or <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\">Facebook<\/a>. If you have any questions, send email to me at <a target=\"_blank\" href=\"mailto:scripter@microsoft.com\">scripter@microsoft.com<\/a> or post them on the <a href=\"http:\/\/social.technet.microsoft.com\/Forums\/en\/ITCG\/threads\/\">Official Scripting Guys Forum.<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p>&nbsp;<\/p>\n<p><b>Ed Wilson, Microsoft Scripting Guy<\/b><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Summary: The Microsoft Scripting Guys show how to use .NET Framework classes to configure the Windows PowerShell console. &nbsp; Hey, Scripting Guy! I am curious about how the .NET Framework classes work. I saw posts from a couple weeks ago, but I still have questions. For example, it seems that the Windows PowerShell console [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[66,51,3,4,45],"class_list":["post-16571","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-net-framework","tag-getting-started","tag-scripting-guy","tag-scripting-techniques","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>&nbsp; Summary: The Microsoft Scripting Guys show how to use .NET Framework classes to configure the Windows PowerShell console. &nbsp; Hey, Scripting Guy! I am curious about how the .NET Framework classes work. I saw posts from a couple weeks ago, but I still have questions. For example, it seems that the Windows PowerShell console [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/16571","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\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=16571"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/16571\/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=16571"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=16571"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=16571"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}