I am running a script that checks if the write time of a file is the correct updated one to today’s date. Is there a way to run this on more than one file in the same script? this is what i have so far that does it for just one file:
#Model to Email for failed daily jobs
$Path = '\\(filelocation)'
$File = Get-Item -Path $Path
$today = (Get-Date).Date
$To = Get-content C:\Daily\List.txt
$From = 'email@email.com'
$Subject = 'Daily- ( ) Drop'
$Server = 'servernamefill'
If($File.LastWriteTime.Date -ne $today)
{
$Body = '(Jobname) Job: Failed'
$properties = @{
to = $To
from = $From
subject = $Subject
Body = $Body
smtpserver = $Server
}
Send-MailMessage @properties
}
What i need is it to check for 3 separate files
$Path = '\(filelocation)'
$Path2 = '\(filelocation)'
$Path3 = '\(filelocation)'
$File = Get-Item -Path $Path
$File2 = Get-Item -Path $Path2
$File3 = Get-Item -Path $Path3
then verify:
if any of the variable $File, $File2, $File3 .LastWriteTime.Date -ne $today)
it will then send the email with the original settings.
Could anyone help me figure out how to set that up ive tried a few things but so far i havent got it
Thank you in advance!