使用powershell读取文本文件仅在powershell屏幕命令上有效,而不能从脚本中读取

时间:2019-05-24 08:56:29

标签: powershell

我想编写一个Powershell命令以使用Get-Content命令从文本文件读取。 但是Get-Content仅在Windows Powershell上有效,而在使用它的脚本上则无效。

enter image description here

这是使用该命令并由powershell本身执行的脚本。

Get-Content "C:\Users\thang.hoang\Desktop\New folder\New folder\New folder - Copy\ProjectName.txt"
read -p "Enter to continue"

enter image description here

它根本不起作用。要运行该命令我会错过吗?

1 个答案:

答案 0 :(得分:0)

我感觉脚本文件格式有问题... 就像我看到的那样,您调用。\ test2.sh并不是有效的powershell脚本结尾。 如果要将脚本作为Powershell脚本执行,请尝试以.ps1结尾。