I am curious how to produce a distinct file list based on this example.
** This example produces a list of all .ps1 and .psm1 files that contain the 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 duplicate file output (same file but different line numbers).
How can I keep my file output distinct?
The current undesirable output:
- C:\Workspace\mydirectorytosearch1\anonymize-psake.ps1:4:. "$($folders.example.test)\anonymize\Example.vars.ps1"
- C:\Workspace\mydirectorytosearch1\anonymize-psake.ps1:5:. "$($folders.missles)\extract\build-utilities.ps1"
The desired output:
- C:\Workspace\mydirectorytosearch1\anonymize-psake.ps1
Help me tweak my script??