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 -
My PowerShell window after I ran a command -
添加-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.