【发布时间】:2014-11-18 08:23:44
【问题描述】:
我的环境中有一台旧的 Windows Server 2000 服务器,它不会针对服务器 2012 DC 进行身份验证。当我们升级此服务器时,我必须确保它始终指向 Server 2008 R2 DC。我想出的最佳解决方案是一个基本批处理文件,我将每 5 分钟运行一次(计划任务),以首先检查它指向的 DC,并在必要时进行更改。我还想将这些记录到一个标有时间和日期的文本文件中
我知道我要编写的脚本,但不知道批处理文件中用于 IF ELSE 的语法。你可以忽略命令实际上在做什么我对语法更感兴趣
我尝试用 JavaScript 编写脚本
if(nltest /server:ServerName123 /sc_query:branch === DCName01)
{
\\I would like it to do nothing apart from write to a text file that it succeeded
Print to a text file ("Ponting to DCNAME01 with time and date");
{
else
{
\\I would like it to run the following command to point the server to the correct DC
nltest /server:ServerName123 /sc_reset:branch\DCName01;
Print to a text file "("Changed to DCNAME01 with time and date");
}
谢谢
【问题讨论】:
-
是什么让您无法使用 Google?而不是写下所有这些,你可以搜索......
标签: windows batch-file if-statement syntax