1

I want to the script to prompt for the string pattern in the select-string. How can I do that ?

$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

1 Answer 1

3

Use Read-Host before calling Get-ChildItem.

$pattern = Read-Host
gci -recurse C:\Enlistment\DAX62\source\*| SELECT-STRING -pattern $pattern >text.txt
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.