New
#21
Brilliant @das10,
That is SOO much better than my LONG brute force approach. I tested it out and it gives EXACTLY what I wanted.
I have tweaked it slightly and added aTotal
. . .
Code:$Source_File = 'C:\Users\System-Admin\Desktop\System_Reports.bat' $Destination_File = 'C:\Users\System-Admin\Desktop\ZZZ.txt' $Find_This = '\%~{0,1}\w{1,50}~{0,1}\%' $Find_Also = '\!~{0,1}\w{1,50}~{0,1}\!' if (Test-Path $Destination_File) {Remove-Item $Destination_File} Select-String -Path $Source_File -Pattern $Find_This -AllMatches | % { $_.Matches } | % { $_.Value } | Sort | Unique | Out-file -FilePath $Destination_File Select-String -Path $Source_File -Pattern $Find_Also -AllMatches | % { $_.Matches } | % { $_.Value } | Sort | Unique | Out-file -FilePath $Destination_File -Append (Get-Content -Path $Destination_File).Length | Out-file -FilePath $Destination_File -Append
EDIT:
I extended the Parameter to\w{1,50}
to include some of the built-inwmic
variables, and it worked GREAT!