powershell - 在Powershell中提示输入

标签 powershell batch-file cmd powershell-2.0

我想让脚本提示选择字符串中的字符串模式。我怎样才能做到这一点 ?

$FileExists = (Test-Path C:\Users\v-hshabb\Desktop\text.txt)
echo $FileExists
If (($FileExists)) 
{
echo $FileExists
  Remove-Item C:\Users\v-hshabb\Desktop\text.txt
}

GET-CHILDITEM  -recurse C:\Enlistment\DAX62\source\*| SELECT-STRING -pattern "@GLS150005"    >text.txt

最佳答案

在调用Get-ChildItem之前,请使用Read-Host。

$pattern = Read-Host
gci -recurse C:\Enlistment\DAX62\source\*| SELECT-STRING -pattern $pattern >text.txt

关于powershell - 在Powershell中提示输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14796413/

相关文章:

windows - 在 Windows CMD FOR 循环中使用 youtube-dl 会去除非 ASCII 字符

powershell - 有没有办法从 PowerShell 中的调用模块范围访问函数?

azure - 如何从 Azure Site Recover 获取所有 protected 项目及其详细信息

powershell - 在 Powershell 中处理字符串参数的 bool 值

powershell - 调用 Get-Service 时过滤服务

java - 启动嵌入式 Tomcat 并从命令行打开浏览器

batch-file - 如何从批处理文件创建空文本文件?

batch-file - 如何在文件夹和子文件夹中的所有 Jpeg 图像上运行 guetzli

python - 在 python 中运行需要用户输入的 .bat 文件

batch-file - 如何在批处理文件中转义波形符 (~),并将其替换为其他字符?