OneNote 部署指南

重要

OneNote for Windows 10 将于 2025 年 10 月终止支持。 建议所有企业客户从 OneNote for Windows 10 切换到 Windows 上的 OneNote,后者可从 Microsoft 应用商店获取,并且订阅为 Microsoft 365。 Windows 上的 OneNote 提供新功能和更新,并允许你通过组策略自定义用户设置。

部署 Microsoft 365 应用、Office LTSC 2021 或 Office 2019 时,OneNote 与其他 Office 应用(如 Word、Excel 和 PowerPoint)一起包含在一起。 无需执行其他步骤即可将 OneNote 包含在新的 Office 安装中。 但是,请务必在部署之前检查部署设置,例如,使用 Configuration Manager 中的向导 (current branch) 或 Microsoft Intune。

使用 Office 部署工具 或企业部署软件(如 Microsoft Configuration Manager)在组织中部署 Office 时包含或排除 OneNote。

将 OneNote 添加到 Office 的现有安装

如果在设备上安装 Office 但缺少 OneNote,请使用 Office 部署工具和以下 configuration.xml 文件添加 OneNote。

<Configuration>
   <Add>
      <Product ID="OneNoteFreeRetail">
       <Language ID="MatchInstalled"/>
      </Product>
   </Add>
</Configuration>

部署 OneNote 的免费版本时,一旦用户首次打开 OneNote,许可证会自动更新,以匹配设备上已安装的 Office 版本。

注意

  • 批量许可版本的 Office 不支持使用 OneNoteFreeRetail,例如 Office LTSC Professional Plus 2021 或 Office Standard 2019。 若要将 OneNote 添加回这些版本的 Office,可以运行联机修复。
  • 如果部署 OneNote 的免费增值版本,则转到 “控制面板>程序>程序和功能”时,OneNote 将显示为名为 Microsoft OneNote 家庭版和学生版 2016 的独立条目。

从安装中排除 OneNote

可通过不同的方法将 OneNote 与 Office 一起安装,具体取决于所使用的部署方法,如下表所示。

方法 说明
Office 部署工具 可以在 configuration.xml 文件中使用 ExcludeApp 元素

建议使用 Office 自定义工具 来帮助创建 configuration.xml 文件。
Microsoft Configuration Manager (current branch) 在 Office 365 客户端安装向导中,可以在配置 Office 设置时将 OneNote 设置为 “关” 位置。
Microsoft Intune “配置应用套件 ”页上,可以清除 “选择 Office 应用 ”下拉列表中 OneNote 的复选框。

但是,如果你允许用户从 Office 365 门户自行安装 Office,则无法排除 OneNote 的安装。

OneNote for Windows 10 迁移指南

注意

为确保服务和工作流不间断,强烈建议组织在 2025 年 10 月 OneNote for Windows 10 终止支持日期之前迁移到 Windows 上的 OneNote。

本部分提供分步指南,可帮助你制定迁移策略并顺利执行转换。

迁移策略开发:为了便于成功迁移到 Windows 上的 OneNote,组织应:

自定义迁移脚本。

使用此示例脚本来满足组织的需求。

#############################################
######   OneNote for Windows 10  ############
######   External Migration Script v5  ######
#############################################

## Creates backupFolder and writes log from script to UWPMigrationResult.log File and Console ##

function writeLogsToFileAndConsole {
    Param ([string]$logstring)
    $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
    $logstringWithTimestamp = "[$timestamp] $logstring"
    $backupFolder = [System.Environment]::GetFolderPath('LocalApplicationData') + "\Microsoft\OneNote\16.0\Backup"
    $outputFile = $backupFolder + "\UWPMigrationResult.log"

    if (-not (Test-Path $backupFolder)) {
        New-Item -Path $backupFolder -ItemType Directory
    }

    if (-not (Test-Path $outputFile)) {
        New-Item -Path $outputFile -ItemType File
    }

    Add-content $outputFile -value "$logstringWithTimestamp"
    Write-Host "$logstringWithTimestamp"
}

## Checks if OneNote UWP is installed and if app data exists, writes version to log file and console ##

function checkOneNoteUWPInstall {
    $folderPath = "$env:LOCALAPPDATA\Packages\Microsoft.Office.OneNote_8wekyb3d8bbwe\LocalState\AppData\Local\OneNote"
    $uwpApp = Get-AppxPackage | Where-Object {$_.Name -eq "Microsoft.Office.OneNote"}
    if ($null -ne $uwpApp) {
    $uwpVersion = $uwpApp.Version
    $uwpVersionObject = [System.Version]$uwpVersion
        writeLogsToFileAndConsole "UWP OneNote app version: $uwpVersion"
    } else {
        writeLogsToFileAndConsole "OneNote UWP App is not installed"
    exit
    }

    if (Test-Path $folderPath) {
        Write-Host "AppData folder detected"
    } else {
        ($null -ne $uwpApp) 
        $uwpApp | Remove-AppxPackage
        writeLogsToFileAndConsole "AppData folder does not exist and OneNote UWP will now be uninstalled"
    exit
    }
}

## Checks if OneNote Win32 is installed by checking the existence of the executable file and checks the version ##

function checkOneNoteWin32Install {
    $oneNotePath = Join-Path $env:ProgramFiles "Microsoft Office\root\Office16\ONENOTE.EXE"
    $registryPath = "HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration"
    $versionValueName = "ClientVersionToReport"
    $registry = Get-ItemProperty -Path $registryPath
    
    if (Test-Path $oneNotePath) {
        if ($registry.PSObject.Properties[$versionValueName]) {
            $versionValue = $registry.$versionValueName
            writeLogsToFileAndConsole "OneNote Win32 Version Value: $versionValue is installed at path $oneNotePath"   
    } else {
        writeLogsToFileAndConsole "OneNote Win32 is not installed"
        exit
    }
 }   

## Checks for backup folder path
  
    $registryPath = "HKCU:\SOFTWARE\Microsoft\Office\16.0\OneNote\Options\Paths"
    $backupValueName = "BackupFolderPath"
    if (Test-Path $registryPath) {
        $registry = Get-ItemProperty -Path $registryPath
        if ($registry.PSObject.Properties[$backupValueName]) {
            $backupValue = $registry.$backupValueName
            writeLogsToFileAndConsole "OneNote Win32 Backup Path Value: $backupValue"
        }
    }
}

## Updates OneNote for Windows 10 to the latest version available ##

function updateUWPVersion {
    $uwpApp = Get-AppxPackage | Where-Object {$_.Name -eq "Microsoft.Office.OneNote"}
    if ($null -ne $uwpApp) {
        $uwpVersion = $uwpApp.Version
        $uwpVersionObject = [System.Version]$uwpVersion

        $updatedVersion = "16001.14326.22008.0"
        $updatedVersionObject = [System.Version]$updatedVersion

        $unsupportedVersion = "16001.14327.10000.0"
        $unsupportedVersionObject = [System.Version]$unsupportedVersion

    if ($uwpVersionObject -ge $unsupportedVersionObject)
        {
        writeLogsToFileAndConsole "Unsupported version of OneNote UWP app. Please check the Microsoft Store for updates"
            exit
    }

    if ($uwpVersionObject -lt $updatedVersionObject)
        {
            writeLogsToFileAndConsole "You must upgrade OneNote UWP to a version higher than 16.0.14326.21802. Please check the Microsoft Store"
            exit
        }
    else
        {
            writeLogsToFileAndConsole "OneNote UWP will backup and uninstall"
        }
    }
    else
    {
        writeLogsToFileAndConsole "No OneNote UWP detected therefore no need for migration"
        exit
    }
}
## Terminates the OneNote for Windows 10 app before executing the rest of the migration script ##

function killProcess {
    if (Get-Process -Name "OneNoteIm" -ErrorAction SilentlyContinue)
    {
        try
        {
            $uwpProcess = Get-Process -Name "OneNoteIm"
            Stop-Process -Id $uwpProcess.Id -Force
            Start-Sleep -Seconds 10
        }
        catch
        {
            writeLogsToFileAndConsole "An error occurred when killing the current OneNote UWP process: $($_.Exception.GetType().FullName)"
            writeLogsToFileAndConsole "$($_.Exception.Message)"
            exit
        }

        writeLogsToFileAndConsole "OneNote UWP process killed"
    }
}

function launchBackUp {
    try
    {
        Start-Process "onenote-uwp://backup:"
        Start-Sleep -Seconds 60
        writeLogsToFileAndConsole "OneNote UWP backup initiated"
    }
    catch
    {
        writeLogsToFileAndConsole "An error occurred when starting the backup: $($_.Exception.GetType().FullName)"
        writeLogsToFileAndConsole "$($_.Exception.Message)"
        exit
    }

    writeLogsToFileAndConsole "OneNote UWP backup in progress"
}

## Parses the results in the json files to validate that the backup was successful ##

 function parseJson {
    try
    {
        $localAppDataPath = [System.Environment]::GetFolderPath('LocalApplicationData')
        $jsonPath = "$localAppDataPath\Packages\Microsoft.Office.OneNote_8wekyb3d8bbwe\LocalState\AppData\Local\OneNote\16.0\UWPBackUpStatus.json"
        if(!(test-path $jsonPath)){
            writeLogsToFileAndConsole "Backup Json file path is not valid"
            exit
        }
        $backupJsonFileContent = Get-Content -Path $jsonPath -Raw | ConvertFrom-Json
        $status = $backupJsonFileContent."UWP Backup Status"
        if ($status -eq "Completed") {
            $jsonPath2 = "$localAppDataPath\Packages\Microsoft.Office.OneNote_8wekyb3d8bbwe\LocalState\AppData\Local\OneNote\16.0\UWPSyncStatus.json"
            if(test-path $jsonPath2)
            {
            $syncStatusJsonContent = Get-Content -Raw -Path $jsonPath2
            $syncStatusJsonObject = COnvertFrom-Json $syncStatusJsonContent
            foreach ($key in $syncStatusJsonObject.PSObject.Properties)
            {
                $value = $syncStatusJsonObject.$($key.Name)
                if ($value.StartsWith("Contains pending outbounding changes: true,"))
                {
                    if ($backupJsonFileContent."Number of sections Backed up" -eq 0)
                    {
                        writeLogsToFileAndConsole "No error occurred when backing up but outbounding changes were not backed up successfully"
                        exit
                    }
                    else
                    {
                        break
                    }
                }
            }
        }

            writeLogsToFileAndConsole "OneNote UWP backup is completed and status is saved"
        }
        elseif ($status -eq "")
        {
            writeLogsToFileAndConsole "$status"
            writeLogsToFileAndConsole "No error occurred but backup did not finish. We cannot continue migration. Consider increasing the Start-Sleep time in line 130 and rerun the script"
            exit
        }
        else
        {
            writeLogsToFileAndConsole "No error occurred but backup status is $status. We cannot continue migration. Consider increasing the Start-Sleep time in line 130 and rerun the script"
            exit
        }
    }
    catch
    {
        writeLogsToFileAndConsole "An error occurred when finishing the backup: $($_.Exception.GetType().FullName)"
        writeLogsToFileAndConsole "$($_.Exception.Message)"
        exit
    }
}

## Copies the backup files to the local app data folder ##

 function moveBackup {
    try
    {
        $localAppDataPath = [System.Environment]::GetFolderPath('LocalApplicationData')
        $sourcePath = "$localAppDataPath\Packages\Microsoft.Office.OneNote_8wekyb3d8bbwe\LocalState\AppData\Local\OneNote\16.0\BackUp\"
        $destinationPath = [System.Environment]::GetFolderPath('LocalApplicationData') + "\Microsoft\OneNote\16.0\Backup\"

        Copy-Item -Path $sourcePath\* -Destination $destinationPath -Recurse -Force

        $sourcePath = "$localAppDataPath\Packages\Microsoft.Office.OneNote_8wekyb3d8bbwe\LocalState\AppData\Local\OneNote\16.0"
        $fileExtensions = "*.json", "*.txt"
        foreach ($fileExtension in $fileExtensions)
        {
            $files = Get-ChildItem -Path $sourcePath -Filter $fileExtension
            foreach ($file in $files) {
                Copy-Item -Path $file.FullName -Destination $destinationPath -Force
            }
        }
    }
    catch
    {
        writeLogsToFileAndConsole "An error occurred when moving the backup files: $($_.Exception.GetType().FullName)"
        writeLogsToFileAndConsole "$($_.Exception.Message)"
        exit
    }

    writeLogsToFileAndConsole "Backup files copied successfully from $sourcePath to $destinationPath"
 }

function uninstallUWP {
    $uwpApp = Get-AppxPackage | Where-Object {$_.Name -eq "Microsoft.Office.OneNote"}
    if ($null -ne $uwpApp) {
        $uwpApp | Remove-AppxPackage
        writeLogsToFileAndConsole "OneNote UWP version uninstalled"
    }
}

function MainRoutine {
    checkOneNoteWin32Install
    checkOneNoteUWPInstall
    updateUWPVersion
    launchBackUp
    killProcess
    parseJson
    moveBackup
    uninstallUWP
}

## Executes the main routine ##

MainRoutine

确保脚本执行以下功能:

  • 在用户设备上在 Windows 上安装 OneNote。 有关更多详细信息,请参阅部署指南部分。

  • 将 OneNote for Windows 10 更新 为最新版本 (最低版本 16001.14326.21802.0) ,以整合防止在迁移未同步笔记期间丢失数据的基本功能。

  • 终止所有 OneNote for Windows 10 进程。

  • 使用 onenote-cmd://backup: 命令将任何未同步的笔记本备份到用户的备份文件夹。

    • 备份存储在 中 C:\temp\OneNoteMigration,但是,可以随意编辑路径以满足组织的需求。
    • 每个备份都会为每个笔记本创建一个相应的文件夹,其中包含此路径中的未同步分区。
  • UWPBackUpStatus.json分析验证备份是否成功。

    • 使用失败的备份进行卸载可能会导致数据丢失。
  • 卸载 OneNote for Windows 10。

    • 确保 OneNote for Windows 10 是基于用户而不是在设备上卸载的。 此过程有助于缓解共享设备删除所有帐户的未同步笔记的情况。

访问迁移的笔记

迁移后,用户可以通过以下方式检索其笔记:

  1. Windows 上打开新的 OneNote 应用程序。
  2. 登录到其帐户。
  3. 打开其笔记本。

如果缺少任何备注,请检查在前面的步骤中创建的备份文件夹。

若要在 Windows 上通过 OneNote 查看备份,请执行以下操作:

  • 导航到 “文件 ” -> 打开备份 -> 导航到备份文件路径。

疑难解答

  • UWPBackupStatus.json有关备份和UWPSyncStatus.json同步状态的详细信息,请查看用户的备份文件夹中的 和 文件。

  • 有关迁移过程中遇到的错误,请参阅位于前面 (步骤 1.d) 生成的备份中的日志文件。

onenote-cmd://backup:如果命令失败:

  • 确保 OneNote for Windows 10 应用是链接到 onenote-cmd 协议的默认应用。
  • 请参阅相关支持文章,确保 OneNote for Windows 10 的协议附件正确。

警告

使用联机找到的命令时请谨慎。 在组织范围内部署命令之前,始终在受控环境中测试命令,以避免意外后果,例如 Remove-AppxPackage 命令导致的后果。

如需更多帮助或查询,请联系Microsoft支持。

有关部署 OneNote 的其他信息

OneNote 培训资源

我们将提供免费 且可共享的电子书 ,以帮助用户过渡到 OneNote 中的用户界面和功能。

配置 OneNote 设置

可以使用组策略为用户配置某些 OneNote 设置。 若要使用组策略,请从 Microsoft 下载 中心 (ADMX/ADML) for Office 的最新管理模板文件 ,并使用 Active Directory 域服务 (AD DS) 实现策略设置。

注意

  • 组策略要求将具有 OneNote 的设备加入到 Active Directory 域。
  • 大多数相同的策略设置都可以使用 云策略应用,云策略不需要设备加入域。
  • 组策略不能与 Microsoft 365 商业应用版或 OneNote for Windows 10 配合使用。
  • 云策略只能与 Microsoft 365 企业应用一起使用。

支持的语言

虽然 OneNote 和 OneNote for Windows 10 在大多数相同的语言中都可用,但存在一些差异。 此处提供了受支持语言的列表: OneNoteOneNote for Windows 10

其他平台

还有 OneNote for Mac、iPad、iPhone、Android 和 Web 浏览器版本。 有关详细信息,请参阅 OneNote 版本之间的区别是什么?