How to Reset PowerShell Colors

Sheeraz Gul Feb 02, 2024
  1. Reset PowerShell Colors by Setting it to Default Manually
  2. Reset PowerShell Colors by Deleting Registry Entries
  3. Reset PowerShell Colors by Editing the Profile
  4. Reset PowerShell Colors by Using the CLI Command
  5. Reset PowerShell Colors by Deleting PowerShell Shortcuts
  6. Conclusion
How to Reset PowerShell Colors

Customizing the appearance of the PowerShell console is a common practice among users to create a personalized and visually comfortable development environment.

However, there are instances where you may want to reset the PowerShell console colors to their default settings. In this article, we will explore five effective methods to achieve this.

We will provide a detailed walkthrough of each method, accompanied by an explanation for better understanding.

Reset PowerShell Colors by Setting it to Default Manually

Resetting PowerShell colors by setting them to default manually involves manually adjusting the console colors to their default values using the settings available in the PowerShell console properties.

Here’s a general explanation of the steps you might take:

  • Start PowerShell to access the console.
  • Right-click on the title bar of the PowerShell console window and select Properties from the context menu. This opens the Properties window.
  • In the Properties window, navigate to the Colors or a similar tab. This is where you can customize the console colors.
  • Look for an option that allows you to reset the colors to their default values.

    The exact wording may vary depending on your version of PowerShell or Windows. It might be labeled as Defaults, Restore Defaults, or something similar.

  • After selecting the option to reset to default colors, apply the changes. This might involve clicking an OK or Apply button.

By manually setting the console colors to their default values, you revert any customizations made to the colors and return them to the standard settings.

Keep in mind that this method primarily affects the appearance settings within the console window and may not address color customizations made through other means, such as PowerShell profile scripts or registry modifications.

Note: If color changes persist after using this method, you may need to investigate other sources of customization.

This method is straightforward and suitable for users who prefer a default graphical interface.

Reset PowerShell Colors by Deleting Registry Entries

Resetting PowerShell colors by deleting registry entries involves modifying the Windows Registry to reset the console colors used by PowerShell. PowerShell console colors are stored in the Windows Registry, and by deleting specific registry entries, you can revert the console colors to their default settings.

However, it’s important to exercise caution when working with the Windows Registry, as making incorrect changes can impact system stability. Before modifying the registry, it’s recommended to create a backup or system restore point.

The specific registry entries related to PowerShell console colors are usually found in the following registry path:

HKEY_CURRENT_USER\Console

Deleting or modifying entries within this path can reset the console colors for PowerShell. Typically, entries related to PowerShell console colors have names like ColorTable00, ColorTable01, and so on.

Keep in mind that manual manipulation of the registry should be done carefully, and it’s often more convenient and safer to use built-in PowerShell commands or settings to customize console colors rather than directly editing the registry.

Code Example:

# Open the Registry Editor
$regEditPath = "Registry::HKEY_CURRENT_USER\Console"
$consoleKey = "PowerShell"

# Delete the registry key for PowerShell colors
Remove-Item -Path "$regEditPath\$consoleKey" -Recurse

In the code snippet above, we use PowerShell to interact with the Windows Registry. The $regEditPath variable is set to the Registry path for console settings.

The $consoleKey variable specifies the PowerShell console. The Remove-Item cmdlet is then used to delete the entire registry key, effectively resetting the console settings.

Reset PowerShell Colors by Editing the Profile

Resetting PowerShell colors by editing the profile involves modifying the PowerShell profile script to change the console color settings.

The PowerShell profile is a script that automatically runs when you start a PowerShell session. By editing this script, you can customize various aspects of the PowerShell environment, including colors.

To reset PowerShell colors by editing the profile:

  • Open your PowerShell profile script. The profile script may be named Microsoft.PowerShell_profile.ps1 or similar and is typically located in your user profile directory. If it doesn’t exist, you can create it.
  • Look for lines of code that set console color preferences. These lines might use cmdlets like Set-Host or similar.
  • Save the changes to the profile script.
  • Restart PowerShell to apply the changes. The modified profile script will automatically run when you start a new PowerShell session.

Keep in mind that manually editing the profile script requires attention to detail, and it’s a good practice to back up the script before making changes. Additionally, there are built-in PowerShell commands (Set-Host, $Host.UI.RawUI.ForegroundColor, etc.) that you can use within the profile script to customize colors without directly editing the registry or profile files.

Reset PowerShell Colors by Using the CLI Command

Resetting PowerShell colors by using the CLI command involves executing specific PowerShell commands or cmdlets from the command-line interface (CLI) to modify the console color settings. This method allows you to make changes directly from the PowerShell command line or from a script without manually editing configuration files or the Windows Registry.

The steps typically involve:

  • Open a PowerShell session.
  • Execute the commands to apply the changes. For example, you might use commands to reset foreground and background colors to their default values.
  • Optionally, save these commands in a script for convenience or to apply the changes automatically each time you start a new PowerShell session.

Using CLI commands for resetting PowerShell colors is a more dynamic and interactive approach, allowing you to experiment with color settings in real time. It also provides a scriptable way to automate color changes as needed.

Keep in mind that any changes made using this method will apply to the current session, so incorporating these commands into your PowerShell profile script can make them persistent across sessions.

Reset PowerShell Colors by Deleting PowerShell Shortcuts

The last method is to delete the PowerShell shortcuts.

Resetting PowerShell colors by deleting PowerShell shortcuts involves manipulating the shortcuts used to launch PowerShell in the Windows environment. This method is a bit indirect, as it relies on the fact that the shortcut properties store specific configurations, including the console colors.

Follow the steps below:

  • First of all, make sure PowerShell is not open.
  • Go to the folder described in the path below:
    C:\Users\Your UserName\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Windows PowerShell
    

    Note: The AppData folder is a Hidden Folder.

  • Delete all the shortcuts.
  • Download the default shortcuts from here.
  • Extract the zip file and copy the PowerShell shortcuts to the above path.
  • Open PowerShell. It will reset to the default settings, which also include the colors.

Keep in mind that this method primarily targets the appearance settings associated with the shortcut and may not affect the colors if they are set elsewhere, such as in a profile script or through other means.

While deleting shortcuts can reset certain settings, it might not address all color-related customizations made within PowerShell. If color changes are controlled by scripts or configurations within PowerShell itself, directly modifying those scripts or configurations may be more effective for a comprehensive reset.

Conclusion

In this article, we explored five methods for resetting PowerShell console colors to control your PowerShell environment. By following the provided examples and explanations, you can easily reset your PowerShell console colors based on your specific needs.

Experiment with these methods to find the one that best fits your workflow, ensuring a seamless and personalized PowerShell development experience.

Author: Sheeraz Gul
Sheeraz Gul avatar Sheeraz Gul avatar

Sheeraz is a Doctorate fellow in Computer Science at Northwestern Polytechnical University, Xian, China. He has 7 years of Software Development experience in AI, Web, Database, and Desktop technologies. He writes tutorials in Java, PHP, Python, GoLang, R, etc., to help beginners learn the field of Computer Science.

LinkedIn Facebook

Related Article - PowerShell Color