While this was a really easy way to change some of the settings, what if you want to do more extensive changes to your PowerShell console? For example, what if you want to change the text and background colors of error messages from red on black to something a little less drastic? For that, you’ll need to get down and dirty and use the console itself rather than rely on GUI. First off, to know the default colors, go ahead and copy/paste this code on the PowerShell console and press ‘Enter’: $host.privatedata

To change the foreground and background colors of error messages, all you need to do is assign new values. Since I’d like to change the background color to ‘Magenta’ and foreground color to ‘Green’, I’ll input the two commands below. Just remember to enter them separately and press ‘Enter’ in each case.
$host.PrivateData.ErrorBackgroundColor = "Magenta"
$host.PrivateData.ErrorForegroundColor = "Green"

You have now configured your console settings, but you’ll need to save them to your profile settings so that the screen opens up exactly as you want it to, every time. For that, first run the command $profile. This will show you the name (and location) of the default file for your profile.

In reality, though, the default PowerShell configuration file does not even exist in most cases. So run the following command to check if it already exists or if you need to create it from scratch: test-path $profile. If the file already exists, you’ll get a “True” output, else, you’ll get “False”.

As you can see from the above screenshot, I got the latter, so I’ll need to create the file. If you get “True”, skip this step and go to the next. Else, enter the following command to create the file: New-Item -path $profile -type file -force

Once the file is created, you can easily edit it with Notepad by using the notepad $profile command in the Powershell Window. From there, you can add whatever configuration code you want to using the commands discussed above. You can not only change colors, but also fonts, windows size, etc through this method, but we’re only going to take a look at changing colors without complicating matters any further.

$console = $host.ui.rawui
$console.backgroundcolor = "black"
$console.foregroundcolor = "white"
$colors = $host.privatedata
$colors.verbosebackgroundcolor = "Magenta"
$colors.verboseforegroundcolor = "Green"
$colors.warningbackgroundcolor = "Red"
$colors.warningforegroundcolor = "white"
$colors.ErrorBackgroundColor = "DarkCyan"
$colors.ErrorForegroundColor = "Yellow"
set-location C:\
clear-host

We’re almost there, but there’s one last step. Run the following command to permit local scripts to run on your system: Set-ExecutionPolicy RemoteSigned and select “A” to allow all scripts. Now that you’re done, this is how your PowerShell console would look every time you start it up. Even the errors messages would look a little less jarring than they normally do.

That’s it, folks, I’ve made the Windows PowerShell console on my work laptop look almost exactly like the good old Command Prompt with just a dash of color thrown in for fun.

Ref:https://beebom.com/how-change-powershell-color-scheme-windows-10/

How to Change Error Message Colors in Windows 10 PowerShell Console的更多相关文章

  1. Windows 10 powershell 中文乱码解决方案

    Windows 10 powershell 中文乱码解决方案 Intro 我装的系统是英文版的 win 10 操作系统,最近使用命令行测试接口,发现中文显示一直异常, 使用网上的各种解决方案都没有效果 ...

  2. Error message when you try to modify or to delete an alternate access mapping in Windows SharePoint Services 3.0: "An update conflict has occurred, and you must re-try this action"

    Article ID: 939308 - View products that this article applies to. Expand all | Collapse all Symptoms ...

  3. server error in '/' applecation----Compiler Error Message: CS0016: Could not write to output file 'c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\xx' -- 'Access is denied

    今天在阿里云虚拟机上部署新站点后出现下面的错误:server error in '/' applecation Compiler Error Message: CS0016: Could not wr ...

  4. python+appium 【已解决】真机运行appium报错“WebDriverException: Message: A new session could not be created. (Original error: Command failed: C:\Windows\system32\cmd.exe /s /c.......详见内文

    问题报错提示: selenium.common.exceptions.WebDriverException: Message: A new session could not be created. ...

  5. ON_NOTIFY_REFLECT : Message Reflection for Windows Controls

    转自: https://msdn.microsoft.com/en-us/library/eeah46xd.aspx TN062: Message Reflection for Windows Con ...

  6. Windows 10 SDK 10.0.10069 : The installer failed. User cancelled installation. Error code: -2147023294

    注* 请先跳到文章后面的配置“操作系统的区域设置”部分,然后尝试重试安装VS,如果仍然失败,请看下面内容. 安装UAP SDK失败 Visual Studio 2015 RC Community 安装 ...

  7. Compiler Error Message: CS0016: Could not write to output file 回绝访问

    Compiler Error Message: CS0016: Could not write to output file 'c:\Windows...dll' 拒绝访问 C:\Windows\Te ...

  8. MS SQL错误:SQL Server failed with error code 0xc0000000 to spawn a thread to process a new login or connection. Check the SQL Server error log and the Windows event logs for information about possible related problems

          早晨宁波那边的IT人员打电话告知数据库无法访问了.其实我在早晨也发现Ignite监控下的宁波的数据库服务器出现了异常,但是当时正在检查查看其它服务器发过来的各类邮件,还没等到我去确认具体情 ...

  9. Oracle Error - "OCIEnvCreate failed with return code -1 but error message text was not available".

    ISSUE: When trying to connect to an Oracle database you receive the following error: "OCIEnvCre ...

随机推荐

  1. C# 创建、更改Excel命名区域(NamedRange)

    创建命名区域是指给选定的某个单元格或多个单元格区域设置名称,目的是方便我们在文件中的其他地方对该单元格区域进行引用能够简化公式引用或者方便数据管理.下面记录了具体的C#示例代码.这里创建命名区域分为了 ...

  2. Java设计模式---Strategy策略模式

    参考于 : 大话设计模式 马士兵设计模式视频 1.场景介绍 购物网站上有一个产品,有三个字段,档次,价格,重量. 有些同学喜欢轻的,有些手头紧,想要便宜的,有些喜欢档次高的. 那么我们为了提高网站用户 ...

  3. 判断点在多边形内算法的C++实现

    目录 1. 算法思路 2. 具体实现 3. 改进空间 1. 算法思路 判断平面内点是否在多边形内有多种算法,其中射线法是其中比较好理解的一种,而且能够支持凹多边形的情况.该算法的思路很简单,就是从目标 ...

  4. FineReport数据库连接(oracle+plsql)(1)

    一.  数据库建表 数据库是Oracle12c,工具是plsql.具体操作百度即可,此处不赘述.(图1) 图1 二.  FineReport中建立数据库连接 在上方选项卡中单击服务器,选择定义数据连接 ...

  5. 《SQL CookBook 》笔记-第三章-多表查询-连接查询

    目录 1 内连接(inner join) 1.1 隐式的内连接 1.2 显式的内连接 2 外连接(outer join) 2.1 左连接(left outer join) 2.2 右连接(right ...

  6. 在chrome 怎么通过ajax请求加载本地文件

    在chrome下面用Jquery 的load方法加载本地的html文件时会报错 我百度了一下是因为 谷歌浏览器内核为了安全机制,不允许这样方式访问其他页面,但是可以通过加 --enable-file- ...

  7. 海思uboot启动流程详细分析(三)【转】

    1. 前言 书接上文(u-boot启动流程分析(二)_平台相关部分),本文介绍u-boot启动流程中和具体版型(board)有关的部分,也即board_init_f/board_init_r所代表的. ...

  8. iOS 类方法 、野指针与空指针

    一.类方法: 不依赖于对象,执行效率更高; 能用类方法解决的问题,尽量使用类方法; 类方法中不能直接访问实例变量(成员变量) 二.野指针和空指针是什么?什么时候产生?怎么避免? 只要一个对象被释放了, ...

  9. springboot整合shiro应用

    1.Shiro是Apache下的一个开源项目,我们称之为Apache Shiro.它是一个很易用与Java项目的的安全框架,提供了认证.授权.加密.会话管理,与spring Security 一样都是 ...

  10. 在centos中搭建基于nginx的apt源服务器,整合yum源和apt源在一台服务器

    1.首先关闭防护墙或者设置规则通过且关闭selinux 2.nginx-1.14.2版本(编译安装)-自定义安装路径 3.开启nginx目录浏览 以上步骤请参考前文:https://www.cnblo ...