PowerShell 通过NTP/NT5DS同步时间
来源:互联网 发布:centos 6.5 搭建lamp 编辑:程序博客网 时间:2024/05/16 15:48
PowerShell通过NTP/NT5DS同步时间.
##############################################################################SyncTime.ps1 ##Client time synchronization ##Set the time from ntp server##If the computer is in domain,using NT5DS to synchronize the time to domain hierarchy.Else using NTP to synchronize the time to the server time.windows.com##Hsing Hsu##meng-xing.xu@hp.com##2011.11.1############################################################################param($type,$help)function funHelp(){$helpText=@"DESCRIPTION: NAME:SyncTime.ps1Synchronize the client time. PARAMETERS:-type The type <NTP/NT5DS> of synchronizing the time.-help print help file SYNTAX:SyncTime.ps1Generates an error.You must supply a type name.SyncTime.ps1 -type NTPUsing NTP to synchronize the time to the server "time.windows.com"SyncTime.ps1 -type NT5DSUsing NT5DS to synchronize the time to domain hierarchy.SyncTime.ps1 -help ?Displays the help topic for the script."@ $helpText exit}if($help){ "Obtaining help ..." funhelp}if(!$type){Write-Host "A value for type is required.Try this: SyncTime.ps1 -help ?" -Foreground Yellow}switch($type){ "NTP" { ## set the shell execute policy set-executionpolicy remotesigned ## get the current path $mypath=get-location ## set the NTP server ## NTP = synchronize to manually configured source set-location hklm:system\currentcontrolset\services\w32time\Parameters set-itemproperty . Type NTP ## Set the AnnounceFlags. ##10(2+8) if thats the Default may just mean that it will not announce itself as a time server. ##0 Timeserv_Announce_No, Reliable_Timeserv_Announce_No. The domain controller does not advertise time service. ##1 Timeserv_Announce_Yes. The domain controller always advertises time service. ##2 Timeserv_Announce_Auto. The domain controller automatically determines whether it should advertise time service. ##4 Reliable_Timeserv_Announce_Yes. The domain contoller will always advertise reliable time service. ##8 Reliable_Timeserv_Announce_Auto. The domain controller automatically determines whether it should advertise reliable time service. cd ../Config set-itemproperty . AnnounceFlags 10 ## start the NTPServer cd ../TimeProviders/NtpServer set-itemproperty . Enabled 1 ## set the time source cd ../../Parameters set-itemproperty . NtpServer time.windows.com ## set the location of the path set-location $mypath.path ## stop and restart the w32time server net stop w32time net start w32time ## update the time with the NTP server w32tm /resync } "NT5DS" { ## set the shell execute policy set-executionpolicy remotesigned ## get the current path $mypath=get-location ## set the NTP server ## Nt5DS = synchronize to domain hierarchy [default] set-location hklm:system\currentcontrolset\services\w32time\Parameters set-itemproperty . Type NT5DS ## Set the AnnounceFlags. ## 5 is set the server announces itself as a reliable time source. cd ../Config set-itemproperty . AnnounceFlags 5 ## start the NTPServer cd ../TimeProviders/NtpServer set-itemproperty . Enabled 1 ## set the location of the path set-location $mypath.path ## stop and restart the w32time server net stop w32time net start w32time ## update the time with the NTP server w32tm /resync } DEFAULT {Write-Host "You must supply a value for the type to synchronize the time.Try this: SyncTime.ps1 -help ?" -Foreground Yellow }}
- PowerShell 通过NTP/NT5DS同步时间
- 通过NTP协议进行时间同步
- 通过NTP协议进行时间同步
- Linux从Windows通过NTP同步时间
- Windows局域网通过NTP设置时间同步
- 通过NTP协议进行时间同步
- Linux内网服务器从Windows通过NTP同步时间
- ntp 同步系统时间
- NTP 时间同步
- linux ntp同步时间
- linux ntp时间同步
- NTP时间同步
- NTP时间同步配置
- linux ntp时间同步
- Ntp时间同步
- NTP时间同步
- RAC ntp时间同步
- 时间同步服务器NTP
- IHttpModule与IHttpHandler的区别整理 .
- Android自动测试之benchmark test 简介
- 二叉查找树
- linux下c/c++方式访问curl的帮助手册
- Android 源代码目录结构2- build
- PowerShell 通过NTP/NT5DS同步时间
- C#中实现压缩文件和文件夹 .
- long long是C99标准中新引进的数据类型
- 这年头——
- python初学笔记(五)---实例学python
- 在WIN7里打开TELNET
- 50个提高PHP编程效率的方法
- 在软件代码世界中穿行的感悟
- 哈希表实现