Here is my script to check number of files in a given directory.
Need some help - the script below write to host files found in green and files not found from the list - which works fine
I want to place a condition where all files found in the directory are of today or certain time and no older the 24 hours
if they are older - send the filename and date created via smtp email
if files are of different times created 24 hours apart, smtp email
if all files are created less than 24 hours than copy into a different folder.
here is my script
$folder = 'D:\test'
$files = @(
"xyz.dat",
"two.txt"
)
Write-Host "Folder: $folder."
# Get only files and only their names
$folderFiles = Get-ChildItem -Path $folder -Recurse -File -Name
foreach ($f in $files) {
if ($folderFiles -contains $f) {
Write-Host "File $f was found." -foregroundcolor green
} else {
Write-Host "File $f was not found!" -foregroundcolor red
}
}