Monday, April 25, 2016

PowerShell v3 in a Year Day 13 Clear Host


Topic: Clear-Host
Alias: cls, clear

When working with the console host extensively, I find a need to wipe the slate clean from time to time. Clear-Host is the perfect cmdlet to do the job. When you call Clear-Host, "the function removes all text from the current display, including commands and output that might have accumulated. When complete, it displays the command prompt." Two aliases for Clear-Host are cls and clear. Both will affect only the current display. It is important to keep in mind "it does not delete saved results or remove any items from the session. Session-specific items, such as variables and functions, are not affected by this function." So, you can use Clear-Host without fear it will negatively impact any actual work you are doing unless you explicitly require output in the host. One last caveat is to realize that the behavior of Clear-Host is determined by the host program calls to the cmdlet may result in different responses on different hosts.

Related Post:

0 comments:

Post a Comment

 
Copyright 2009 Information Blog
Powered By Blogger