天天看点

【Powershell】同步整个域时间跟北京时间一致

最近发现整个域的时间比北京晚了近5分钟,部分域外的应用程序在进行身份验证的时候开始报错:

1

<code>According to Microsoft, The internal clock </code><code>for</code> <code>servers must be </code><code>set</code> <code>to within 10 minutes of the domain controller's clock. If the clocks are not synchronized </code><code>then</code> <code>Kerberos authentication will fail。</code>

考虑到域内的所有服务器时间都是跟PDC同步的,只需要设定PDC跟北京时间同步,即可让整个域同步;操作步骤如下:

(1)将time.windows.com作为PDC的权威时间来源;

<code>w32tm /config /update /manualpeerlist:time.windows.com /syncfromflags:manual /reliable:yes</code>

<a href="http://281816327.blog.51cto.com/attachment/201410/22/907015_1413975365lQhq.png" target="_blank"></a>

(2)从DNS中导出域中所有的服务器列表,保存为CSV格式文件;

整理文件格式如下:

(3)手动执行powershell语句,将域内服务器时间与PDC一致;(等待完成即可)

2

<code>$names</code><code>=</code><code>Get-Content</code> <code>d:\dn.csv</code>

<code>foreach</code> <code>(</code><code>$name</code> <code>in</code> <code>$names</code><code>) {w32tm /resync /computer:</code><code>$name</code><code>}</code>

<a href="http://281816327.blog.51cto.com/attachment/201410/22/907015_1413975367bLet.png" target="_blank"></a>

本文转自 bannerpei 51CTO博客,原文链接:http://blog.51cto.com/281816327/1566870,如需转载请自行联系原作者

继续阅读