I've the following task... I want to archive files with an Powershell script that have an specifice creation/edit date. Therefore I started to get a list of these files with the following statemant:
Get-ChildItem -Path C:\Data\... -Recurse | Where-Object { $_.LastWriteTime.Date -gt '2021.01.01' }
This seems to work correctly as I only get the requiered files listed. If I expand the statment to
Get-ChildItem -Path C:\DATA\... -Recurse | Where-Object { $_.LastWriteTime.Date -gt '2021.01.01' } | Compress-Archive -DestinationPath C:\Data\Delta\Archive.zip
the Files that are archived are doubled in the ZIP file. One is the correct set of Files and than all files (also those that are older than the specified date) are added to the archive again.
Can someone tell me what I'm missing?
Thanks in advance
Greatings
Alex