I am wondering how to create a separate file list based on this example.
** This example creates a list of all .ps1 and .psm1 files containing text "folders" but without the text ".invoke" on the same line.
$text='folders' dir C:\Workspace\mydirectorytosearch1\ -recurse -filter '*.ps*1' | Get-ChildItem | select-string -pattern $text | where {$_ -NotLike '*.invoke(*'} dir C:\Workspace\mydirectorytosearch2\ -recurse -filter '*.ps*1' | Get-ChildItem | select-string -pattern $text | where {$_ -NotLike '*.invoke(*'}
This is cool and works well, but I get a duplicate of the file output (same file, but different line numbers).
How can I save my file output?
Current unwanted result:
- C: \ Workspace \ mydirectorytosearch1 \ Anonymization-psake.ps1: 4 :. "$ ($ folders.example.test) \ Anonymization \ Example.vars.ps1" C: \ Workspace \ mydirectorytosearch1 \ Anonymization-psake.ps1: 5 :. "$ ($ Folders.missles) \ extract \ built-in utilities.ps1"
Desired Result:
- C: \ Workspace \ mydirectorytosearch1 \ Anonymization-psake.ps1
Help me customize my script
source share