跳至内容

配置 NTP 时间服务器

本页由 tools/devdocs-generator.ps1 生成,请修改源配置或函数后重新生成。目录保留历史 URL,实际分类以本页为准。

  • 稳定 ID:WPFFixesNTPPool
  • 当前分类:修复
  • 源配置:config/feature.json
  • 源配置 SHA-256:956400006e36b3841c7816500199907bb57de94c98a0f05b1e9ee4737a8ab03c

将 Windows 默认时间服务器(time.windows.com)替换为 pool.ntp.org,以提高校时准确性和稳定性。

配置定义

{
  "WPFFixesNTPPool": {
    "Content": "配置 NTP 时间服务器",
    "Description": "将 Windows 默认时间服务器(time.windows.com)替换为 pool.ntp.org,以提高校时准确性和稳定性。",
    "category": "修复",
    "panel": "1",
    "Type": "Button",
    "ButtonWidth": "300",
    "function": "Invoke-WPFFixesNTPPool",
    "link": "https://winutil.christitus.com/dev/features/fixes/ntppool"
  }
}

入口函数

来源:functions/public/Invoke-WPFFixesNTPPool.ps1。这里只展示入口,其他被调用函数以仓库源码为准。

function Invoke-WPFFixesNTPPool {
    <#
    .SYNOPSIS
        Configures Windows to use pool.ntp.org for NTP synchronization

    .DESCRIPTION
        Replaces the default Windows NTP server (time.windows.com) with
        pool.ntp.org for improved time synchronization accuracy and reliability.
    #>

    Start-Service w32time
    w32tm /config /update /manualpeerlist:"pool.ntp.org,0x8" /syncfromflags:MANUAL

    Restart-Service w32time
    w32tm /resync

    Write-Host "================================="
    Write-Host "-- NTP Configuration Complete ---"
    Write-Host "================================="
}