简体   繁体   中英

The PowerShell window is always cleaned after a script has been executed

I run a PowerShell script form the PowerShell and whatever method I choose it always cleans my current PowerShell window which is pretty annoying. That doesn't happen with Linux PowerShell.

This is how I run a PowerShell script:

powershell.exe -File "/path/to/file.ps1

or

powershell -c ". /path/to/file.ps1"

No matter how I call the script, the current PowerShell window is cleaned and the only thing I can see is the output of the script that I called. All previously displayed text is deleted.

Maybe there are options to prevent this behavior?

See also my screenshots as a visual representation of the problem:

  • My PowerShell window before I ran the command - PS窗口之前

  • My PowerShell window after I ran a command - PS窗口后

添加-NoProfile可以解决问题:

powershell -NoProfile  -c 'Write-Host OK'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM