Solved

Time Sync PowerShell Script

Posted on 2013-12-04
2
993 Views
Last Modified: 2013-12-21
I made a script that will take the time of the PDC and send an email to me with the Time stamp. I verify the timestamp with the time received of the email alert to make sure the time is in sync (at least by a few minutes) for that client. Is there a way to add an ALERT! flag to the header if the time is off by a few minutes?


Powershell Script that I have:

$logfile="C:\users\public\tempinfo.txt"

Get-date | Out-file $logfile

$client =  (gwmi WIN32_ComputerSystem).Domain

$smtpServer = "192.168.0.1"
$smtpFrom = "email@email.com"
$smtpTo = "recipient@mail.com"
$messageSubject = "Time Synchronization Test - $client "

$message = New-Object System.Net.Mail.MailMessage $smtpfrom, $smtpto
$message.Subject = $messageSubject
$message.IsBodyHTML = $true

$message.Body = get-content $logfile

$smtp = New-Object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($message)

Remove-Item $logfile
0
Comment
Question by:Allanore
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 26

Expert Comment

by:Leon Fester
ID: 39697867
Is there a way to add an ALERT! flag to the header if the time is off by a few minutes?

You cannot modify the header of the email as it is created by the SMTP server when the email is processed. Unless you need the header somewhere else.

Not sure what issue you are trying to resolve but on a separate topic; if you have a PDC then you have Active Directory installed. Active Directory allows a time sync difference of 5 minutes on each side of the PDC time. If the time is out by more than this value then the Host OS will try to re-sync the time from the PDC.
0
 
LVL 30

Accepted Solution

by:
Rich Weissler earned 500 total points
ID: 39698051
Interesting.  The only real option I see is to add a priority to the MailMessage.  I know some clients will mark with a red '!' for both 'High Priority' messages or 'High Importance'.
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question