Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Time Sync PowerShell Script

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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
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…

722 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