My goal is to send email to some users to notify about the current count of the files inside some folder directories.
I need to count files only with .
I found the following workaround
just remove the -recurse to exclude subdirectories files in counting and use -filter instead of -include
$path = "D:\LIVE"
$total = Get-ChildItem $path -File -filter *.txt |Where-Object {$_.LastWriteTime} | Measure-Object | ForEach-Object{$_.Count}
-Filter is limited to using one paramter, so if you want to use -include to use as many searching parameter as you can, use Get-Item instead of get-childItem
just add * (when no path is declared) or * appending to the existing path
$path = "D:\LIVE\*"
$total = Get-Item $path -include *.txt, *.xml |Where-Object {$_.LastWriteTime} | Measure-Object | ForEach-Object{$_.Count}