Avatar of dfke
dfke

asked on 

Powershell get dates from log file, compare with current date and set an alert/e-mail notification

Hi,

I have a log file with output in the following format. I put xxxxxxxx because the log contains sensitive data.
There are multiple sections like this one and all are separated by a blank line.

I wish to receive an e-mail/set an alert when if any of the dates in the log are more than 24 hours ago. Just trying to figure out how to read and compare the dates with the current date.

xxxxxxxx                                            : xxxxxxxx
xxxxxxxx                                            : xxxxxxxx
xxxxxxxx                                            : xxxxxxxx
xxxxxxxx                                            : 1/14/2020 5:30:08 AM
xxxxxxxx                                            : 1/14/2020 5:30:06 AM
xxxxxxxx                                            : 1/14/2020 5:30:04 AM
xxxxxxxx                                            : 1/14/2020 5:30:08 AM

Open in new window


If anyone can get me in the right direction if would be very much appreciated.

Cheers
Powershell

Avatar of undefined
Last Comment
dfke
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of dfke
dfke

ASKER

Hi oBdA,

That's perfect! Thanks for your quick reply!

Cheers
Powershell
Powershell

Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. PowerShell provides full access to the Component Object Model (COM) and Windows Management Instrumentation (WMI), enabling administrators to perform administrative tasks on both local and remote Windows systems as well as WS-Management and Common Information Model (CIM) enabling management of remote Linux systems and network devices.

27K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo