Powershell

How to Use the Clear-Host (Microsoft.PowerShell.Core) Cmdlet in PowerShell?

The “Clear-Host” cmdlet in PowerShell clears the display on the host screen. It removes all text from the current display including the commands and output that accumulated. However, it does not delete the saved results or remove any item from the session. This command has no impact on variables or functions. The standard alias for the “Clear-Host” cmdlet is the “cls”.

This post will elaborate on the use of the PowerShell “Clear-Host” cmdlet.

How to Use the Clear-Host Cmdlet in PowerShell?

As it is stated that the “Clear-Host” cmdlet clears the display screen of the PowerShell current session. For that purpose, simply run the “Clear-Host” cmdlet.

Syntax
Here is the syntax for the “Clear-Host” cmdlet:

Clear-Host

Example: Use the “Clear-Host” Cmdlet to Clear the Display Screen
Before clearing the display screen of the PowerShell console, let’s first print date on the screen by executing the provided command:

Get-Date

As you can see, the date and time have been successfully displayed on the screen:

Let’s clear the display screen by executing the provided command:

Clear-Host

That’s it! You have learned the usage of PowerShell’s “Clear-Host” cmdlet.

Conclusion

The “Clear-Host” cmdlet in PowerShell is responsible for clearing the display screen of the current PowerShell session including the commands and output that accumulated. Its standard alias is “cls”. This post has elaborated on the usage of the “Clear-Host” cmdlet in PowerShell.

About the author

Muhammad Farhan

I am a Computer Science graduate and now a technical writer who loves to provide the easiest solutions to the most difficult problems related to Windows, Linux, and Web designing. My love for Computer Science emerges every day because of its ease in our everyday life.