Tuesday, August 31, 2010

Finding the string you need

I use this simple one liner a lot whenever I need to find code that needs to be changed in multiple scripts. I often find myself having to update anywhere from 1 to 80 automated test scripts. This one liner will give me the name of the script and the line number of the string I'm looking for.



# Using select-string

select-string -pattern "get-command" -path "C:\Scripts\*.ps1" | foreach-Object{Write-Host $_.FileName, $_.linenumber}


No comments:

Post a Comment