Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Check for file exsistence

$
0
0

 

Hi Everyone,

I was trying to write a Power shell script to check a folder for files with todays timestamp. If any file with todays file stamp is available then i should get a mail " Files are found " with the file names and timestamp in the contents else i should get a mail " Files are not found " . I tried with the below power shell script but it is not giving the required result. It will be very helpful if some one can help me on this.

$support="dl-support@xyz.com"

$by="dl-notification@xyz.com"

$COntent="This is a test mail for checking the Availablity of  backup file --- Peter"

$Heading=(get-date).ToString()

$today = (get-date).Date;

Get-ChildItem E:\peter\Checkfile\test | where { $_.CreationTime.Date -eq $today };

if ($_ -ne $null)

{

send-MailMessage -to $support -From $by -Body "$Content"  -SmtpServer XX.XX.XX.XX-Subject "! File is Not Available -$Heading !"

}

else

{

Send-MailMessage -to $support -From $by -Body "$Content"  -SmtpServer XX.XX.XX.XX -Subject "! File is  Available -$Heading !"

}

Thanks in Advance.

Peter Sen

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles