Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Converting old server time check batch file to PowerShell

$
0
0

Hi Guys,

I have batch file that checks the offset between our time servers and two external ones.  This batch file works in XP, but not in Windows 7 pro.  Where it breaks down is it doesn't display the offset correctly.  Can this batch be converted to Powershell, so that it would be compatible?  Here is the batch code:

CLS
@ECHO OFF
@ECHO.
@ECHO.
@ECHO ************************* Time Checking Script *************************
@ECHO *** Check the offset between government time server, our internal 
@ECHO *** time server and domain controllers.
@ECHO.
@ECHO *** time.nist.gov:
@w32tm  /monitor /computers:time.nist.gov /domain:cooley-dickinson.org |FIND "offset"
@ECHO.
@ECHO *** time.cooley-dickinson.org:
@w32tm  /monitor /computers:tock.usno.navy.mil /domain:cooley-dickinson.org |FIND "offset"
@ECHO.
PAUSE
@ECHO.
@Net Time \\server1 | find "Current"
@Net Time \\server2 | find "Current"
@Net Time \\server3 | find "Current"
@Net Time \\server4 | find "Current"
@Net Time \\server01 | find "Current"
@Net Time \\server02 | find "Current"
@Net Time \\server03 | find "Current"
@Net Time \\server04 | find "Current"
@Net Time \\server05 | find "Current"
@Net Time \\server06 | find "Current"
@Net Time \\server07 | find "Current"
@Net Time \\server08 | find "Current"

Below is the output we get from the batch file in Windows 7.  Where it says delayoffset, is normally where the offset is in seconds.

*** time.nist.gov:
Analyzing:Analyzing:Analyzing:Analyzing:Analyzing:delayoffset from DC01.coole
y-dickinson.org
delayoffset from DC01.cooley-dickinson.org
delayoffset from DC01.cooley-dickinson.org
delayoffset from DC01.cooley-dickinson.org
delayoffset from DC01.cooley-dickinson.org

*** time.cooley-dickinson.org:
offset from DC01.cooley-dickinson.org
delayoffset from DC01.cooley-dickinson.org
delayoffset from DC01.cooley-dickinson.org
delayoffset from DC01.cooley-dickinson.org
delayoffset from DC01.cooley-dickinson.org

The rest of the script displays the date/time for individual servers correctly.  If this could be converted to powershell, it would be a whole lot easier to deal with.

Thank you!

Larry


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>