Quantcast
Channel: Spiceworks Community - Latest topics
Viewing all articles
Browse latest Browse all 184401

How to send an Emsil in Powershell when a $Pattern matches

$
0
0

Hello, I have a powershell script I want to send an Email only when the $Pattern is a match, It looks through a Log file, and for the current Date if it finds a specific Pattern defined, it should send an Email, it if doens't find the $Pattern match it should do nothing, but But weather it is a match or not, it sends an Email only when "-eq 1" if I try "-eq 0" where there is a match or not no email is sent. Any help would be greatly appreciated

$File = "C:\Data\PS\FTPUpload.log"$Date = Get-Date -Format "MM/dd/yy" $Text = "No Recount Data file found" $Pattern = $date -match $Text $MsgParam = @{ To = "user <user@company.com" From = "script <no-reply-PLFTP@company.com" Subject = "Check CopiTrak Export Process" Body = "No Recount Data file found" Attachment = "C:\Data\PS\FTPUpload.log" smtpServer = "1.2.3.4" } Get-Content $File |...<<


Viewing all articles
Browse latest Browse all 184401

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>