Copy-item with multiple filter

Solution 1:

If you want all the jpg and xml files into one folder, you could use Get-ChildItem -Include:

Get-ChildItem -Include *.jpg,*.xml -Recurse | ForEach-Object { 
    Copy-Item -Path $_.FullName -Destination D:\Users\MS5253\Desktop\Lots
}

Solution 2:

If you need to preserve a folder structure, it seems like there's no other way than manual paths management:

function Copy-Filtered {
    param (
        [string] $Source,
        [string] $Target,
        [string[]] $Filter
    )
    $ResolvedSource = Resolve-Path $Source
    $NormalizedSource = $ResolvedSource.Path.TrimEnd([IO.Path]::DirectorySeparatorChar) + [IO.Path]::DirectorySeparatorChar
    Get-ChildItem $Source -Include $Filter -Recurse | ForEach-Object {
        $RelativeItemSource = $_.FullName.Replace($NormalizedSource, '')
        $ItemTarget = Join-Path $Target $RelativeItemSource
        $ItemTargetDir = Split-Path $ItemTarget
        if (!(Test-Path $ItemTargetDir)) {
            [void](New-Item $ItemTargetDir -Type Directory)
        }
        Copy-Item $_.FullName $ItemTarget
    }
}