Find-SSPFiles.ps1

<#
    .Synopsis
    Finds the names of all the files in a folder that match.
    .Description
    This CmdLet finds all the files that match the matches in a particular folder.
    .Parameter Matches
    This parameter contains list of string matches.
    .Parameter Connection
    This parameter provides the context for the call. The default is the current connection
    returned by "Get-PnPConnection".
    .Example
        PS> Find-SSPFile -Matches ("*.png", "*.jpg") -Folder "SiteAssets"
#>


function Find-SSPFiles {
    param(
        [string] $folder,
        [string[]] $matches,
        $connection = (Get-PnPConnection)
    )
    $results = @()
    if ($matches) {
        foreach ($match in $matches) {
            try {
                Write-Host "Looking for $match in $folder"
                $fs = Find-PnPFile -Match $match -Folder $folder -Connection $connection
            } catch {
                Write-Host "Not Found"
                $fs = @()
            }
            $results = $results + $fs
        }
    } else {
        $results = Find-PnPFile -Match "*" -Folder $folder -Connection $connection
    }
    return $results
}