我希望脚本在select-string中提示输入字符串模式。我怎么能这样做?
$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
答案 0 :(得分:3)
在调用Get-ChildItem之前使用Read-Host。
$pattern = Read-Host
gci -recurse C:\Enlistment\DAX62\source\*| SELECT-STRING -pattern $pattern >text.txt