Clear-Host
In PowerShell, the Clear-Host cmdlet is used to clear the console window or terminal screen. It clears all the previous outputs and makes the console window empty. This can be useful to start fresh or to clear clutter from previous output on the console.
When you execute the Clear-Host cmdlet, PowerShell will clear the screen and move the cursor to the top left of the console window. This is similar to the effect of typing cls or clear in the terminal or command prompt.
The syntax for Clear-Host cmdlet is as follows:
Clear-Host [-WhatIf] [-Confirm] [<CommonParameters>]
The -WhatIf and -Confirm parameters are optional and used to display what will happen if the cmdlet is executed or to prompt for confirmation before executing the cmdlet.
Here is an example of how to use the Clear-Host cmdlet:
PS C:\> Get-ChildItem C:\Windows | Out-String -Width 120 | Write-Host
PS C:\> Clear-Host