I'm trying to make the following PowerShell script more generic. I want to pass in an array of excludes rather than a fixed list. I can't figure out how to do this except my partial solution below:

ORIGINAL

This gets all the files in a path except a list of wildcard files or folders:

```
        Get-ChildItem -Path  "$sitePath" -Recurse | `
        where {!$_.PSIsContainer } | `
        Select -ExpandProperty FullName | `
            Where {$_ -notlike "$sitePath\Custom\*"} | `
            Where {$_ -notlike "$sitePath\Download\*"} | `
            Where {$_ -notlike "$sitePath\Temp\*"} | `
            Where {$_ -notlike "$sitePath\Portal\*"} | `
            Where {$_ -notlike "$sitePath\web.config*"} | `            
            SELECT $_

```

PARTIAL SOLUTION

This is the best I've come up with. It allows me to create an array of wildcards called $excludeList, but is limited and is slightly slower:

```
        $excludeList = @("$sitePath\Custom\*",
                "$sitePath\Download\*",
                "$sitePath\Portal\*",
                "$sitePath\web.config*")

        Get-ChildItem -Path  "$sitePath" -Recurse | `
        where {!$_.PSIsContainer } | `
        Select -ExpandProperty FullName | `
            Where {$_ -notlike $excludeList[0]} | `
            Where {$_ -notlike $excludeList[1]} | `
            Where {$_ -notlike $excludeList[2]} | `
            Where {$_ -notlike $excludeList[3]} | `
            Where {$_ -notlike $excludeList[4]} | `
            Where {$_ -notlike $excludeList[5]} | `
            Where {$_ -notlike $excludeList[6]} | `
            Where {$_ -notlike $excludeList[7]} | `
            Where {$_ -notlike $excludeList[8]} | `
            Where {$_ -notlike $excludeList[9]} | `
            Where {$_ -notlike $excludeList[10]} | `
            SELECT $_

```

Is there a better way to pass an array in to the where clause? All the solutions I've found only allow non-wildcard matches.

Hope someone can help!