i think you're filtering based on something not directly a property or want to evaluate the whole object (like a string or name after ForEach-Object
), you must use the scriptblock form:
Get-ChildItem | ForEach-Object Name | Where-Object { $_ -match '\.(txt|md)$' }