Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Time Sync PowerShell Script

Posted on 2013-12-04
2
Medium Priority
?
1,012 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
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 2000 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

New Tabletop Appliances Blow Competitors Away!

WatchGuard’s new T15, T35 and T55 tabletop UTMs provide the highest-performing security inspection in their class, allowing users at small offices, home offices and distributed enterprises to experience blazing-fast Internet speeds without sacrificing enterprise-grade security.

Question has a verified solution.

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

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
A walk-through example of how to obtain and apply new DID phone numbers to your cloud PBX enabled users that are configured in Office 365. Whether you have 1, 10 or 100+ users in your tenant, it's quite easy to get them phone-enabled and making/rece…
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…
Screencast - Getting to Know the Pipeline

926 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