I am looping through a folder with files, to select some of them accordingly if they match the day that we are currently. I want to output a message if it doesn't file any file that matches the day, but I only what one message to be outputted instead of a message for each file.
Any clues on how to make that happen in my code below:
foreach ($file in Get-ChildItem -Path $directory) {
if ($file.LastWriteTime.Date -eq [datetime]::Today) {
Write-Output "File from today"
} else {
Write-Output "File is not from today"
}
}