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:
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:
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:
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.