Search code examples
shellpowershellcarriage-returnpowershell-ise

Carriage return doesn't work as expected in PowerShell ISE


I have this command:

Write-Host "123`r456" 

Output in stand-alone PowerShell:

456 

Output in PowerShell ISE:

123456 

Thanks.


Solution

  • The ISE doesn't behave like a normal console in many ways. While you would expect the carriage return to reset the position to the first character of a line, and hence give the outout 456, the ISE does not work that way, so do not depend on that behaviour.

    This is one of the undocumented differences of ISE from the normal console. Documented ones are here: http://blogs.msdn.com/b/powershell/archive/2009/04/17/differences-between-the-ise-and-powershell-console.aspx