Solved

Time Sync PowerShell Script

Posted on 2013-12-04
2
971 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
2 Comments
 
LVL 26

Expert Comment

by:Leon Fester
Comment Utility
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 29

Accepted Solution

by:
Rich Weissler earned 500 total points
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now