Hi Forum,
my goal : I need to search for content inside the and of pages in a website for text strings. the problem is, often those strings are found in headers, footers and meta, and our site being over 100k pages, the results are staggering.
My goal with this script is to filter out the pages with a multi-line regular expression, and only the pages that return a result, get select-string’ed again to give me line by line results. Bonus marks, if we can ignore the line numbers before and after
This is my code so far : (for some reason, I cant put more than 9 lines, please use the link)
Errors I get running it are
ForEach-Object : Cannot convert 'System.Object[]' to the type 'System.Management.Automation.ScriptBlock' required by parameter 'Process'. Specified method is not supported.
At W:\test\york\_tools\menu.ps1:41 char:37
+ $result = ForEach-Object <<<< $filter {
+ CategoryInfo : InvalidArgument: (:) [ForEach-Object], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,Microsoft.PowerShell.Commands.ForEachObjectCommand
Export-Csv : Cannot bind argument to parameter 'InputObject' because it is null.
At W:\test\york\_tools\menu.ps1:44 char:33
+ $result | Export-Csv <<<< "W:\test\search_results\$name.csv" -NoType
+ CategoryInfo : InvalidData: (:) [Export-Csv], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ExportCsvCommand
Any insight is greatly appreciated!