【问题标题】:Prompting for input in powershell提示在 powershell 中输入
【发布时间】:2013-01-25 15:01:54
【问题描述】:

我希望脚本提示选择字符串中的字符串模式。我该怎么做?

$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

【问题讨论】:

    标签: powershell batch-file cmd powershell-2.0


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-24
      • 2012-01-10
      • 1970-01-01
      • 2013-12-23
      • 2016-02-12
      • 1970-01-01
      • 2016-03-20
      • 1970-01-01
      相关资源
      最近更新 更多