Author Posts

June 24, 2015 at 12:01 pm

Hi All,

I have this script :

$exclude = ("w:\test\york\SedAwk")
Get-ChildItem -path $path -Recurse -Filter *.html | 
        ForEach-Object {
            If (Get-Content $_.FullName | Select-String -Pattern "Stay Connected") {
                Select-String -InputObject (Get-Content $_.FullName | Where {$_.FullName -notlike $exclude} | Out-String) -Pattern "(?sm)

But I am having a hard time getting it to exclude the SedAwk folder.

How can this be achieved?


June 24, 2015 at 12:57 pm

Try this:

Get-ChildItem -path $path -Recurse -Filter *.html -Exclude "*SedAwk*"

Also, I'm not sure if you just threw the above together for an example, but the Where-Object is not correct in your statement.