linux - 执行脚本后,PowerShell 窗口始终会被清理

标签 linux windows powershell terminal console

我从 PowerShell 运行 PowerShell 脚本,无论我选择什么方法,它总是会清理我当前的 PowerShell 窗口,这非常烦人。 Linux PowerShell 不会发生这种情况。

这是我运行 PowerShell 脚本的方式:

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

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

无论我如何调用脚本,当前的 PowerShell 窗口都会被清理,我唯一能看到的就是我调用的脚本的输出。所有先前显示的文本都将被删除。

也许有一些选项可以防止这种行为?

另请参阅我的屏幕截图作为问题的直观表示:

  • 运行命令之前的 PowerShell 窗口 - PS window before

  • 运行命令后的 PowerShell 窗口 - PS window after

最佳答案

添加-NoProfile解决了问题:

powershell -NoProfile  -c 'Write-Host OK'

关于linux - 执行脚本后,PowerShell 窗口始终会被清理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53326280/

相关文章:

linux - 直写 RAM 磁盘,还是文件系统的海量缓存?

linux - Alsa 无法设置样本格式[FFMPEG]

php - 如何安全部署linux(CentOS)预打包的php mysql应用程序?

windows - Opa:找不到 Nodejs

windows - 如何在 powershell 中关闭 Windows 窗体?

powershell - 在 Powershell 中比较 System.Version

powershell - 如何从PowerShell中的文件读取行

linux - 通过 FIFO 重定向标准输入

windows - windows tcp 堆栈的缓冲区限制,特别是使用 winsocket

python - 使用 python 将一些键发送到非事件窗口