内容库清理工具Content library cleanup tool

适用范围: Configuration Manager (Current Branch)Applies to: Configuration Manager (current branch)

使用内容库清理命令行工具删除不再与分发点上的任何包或应用程序关联的内容。Use the content library cleanup command-line tool to remove content that's no longer associated with any package or application on a distribution point. 此类内容被称为孤立内容 。This type of content is called orphaned content. 此工具替换了针对过去的 Configuration Manager 产品发布的较旧版本的类似工具。This tool replaces older versions of similar tools released for past Configuration Manager products.

该工具只影响你运行该工具时指定的分发点上的内容。The tool only affects the content on the distribution point that you specify when you run the tool. 该工具无法删除站点服务器上内容库中的内容。The tool can't remove content from the content library on the site server.

查找站点服务器上 CD.Latest\SMSSETUP\TOOLS\ContentLibraryCleanup 中的 ContentLibraryCleanup.exe 。Find ContentLibraryCleanup.exe in CD.Latest\SMSSETUP\TOOLS\ContentLibraryCleanup on the site server.

要求Requirements

  • 一次只对一个分发点运行该工具。Only run the tool against a single distribution point at a time.

  • 直接在承载要清理的分发点的计算机上运行,或从另一台计算机远程运行。Run it directly on the computer that hosts the distribution point to cleanup, or remotely from another computer.

  • 运行该工具的用户帐户必须具有与 Configuration Manager 中的“完全权限管理员”安全角色相同的权限 。The user account that runs the tool must have permissions the same as the Full Administrator security role in Configuration Manager.

操作模式Modes of operation

可以在以下两种模式中运行该工具:假设删除Run the tool in the following two modes: What-if and Delete.

提示

从假设模式开始 。Start with the what-if mode. 如果对结果满意,接着在删除模式下运行该工具 。When you're satisfied with the results, then run the tool in delete mode.

假设模式What-if mode

如果未指定 /delete 参数,则在假设模式下运行该工具。If you don't specify the /delete parameter, the tool runs in what-if mode. 此模式标识将从分发点中删除的内容。This mode identifies the content that would be deleted from the distribution point.

  • 在此模式下运行时,该工具不会删除任何数据。When run in this mode, the tool doesn't delete any data.

  • 该工具会向日志文件写入有关它将删除的内容的信息。The tool writes to the log file information about the content that it would delete. 不会提示用户确认每个可能的删除操作。You're not prompted to confirm each potential deletion.

删除模式Delete mode

使用 /delete 参数运行工具时,工具将在删除模式下运行。When you run the tool with the /delete parameter, the tool runs in delete mode.

  • 在此模式下运行时,可从分发点的内容库删除在指定分发点上找到的孤立内容。When run in this mode, orphaned content that it finds on the specified distribution point can be deleted from the distribution point's content library.

  • 删除每个文件之前,用户需确认工具是否应删除该文件。Before deleting each file, confirm that the tool should delete it. 若要删除,请选择“是”;若不删除,请选择“否”;或者选择“删除所有”,跳过后续提示并删除所有孤立内容 。Select Y for yes, N for no, or Yes to all to skip further prompts and delete all orphaned content.

日志文件Log file

当工具以任一模式运行时,会自动创建日志。When the tool runs in either mode, it automatically creates a log. 它使用以下信息命名日志文件:It names the log file with the following information:

  • 该工具运行的模式The mode the tool runs in
  • 分发点的名称The name of the distribution point
  • 操作的日期和时间The date and time of operation

工具结束时,会在 Windows 中自动打开日志文件。When the tool finishes, it automatically opens the log file in Windows.

默认情况下,该工具会将日志文件写入运行该工具的用户帐户的临时文件夹。By default, the tool writes the log file to the temp folder of the user account that runs the tool. 此位置位于运行该工具的计算机上,该计算机并不一定是工具的目标。This location is on the computer where you run the tool, which isn't always the target of the tool. 使用 /log 参数将日志文件重定向到其他位置,包括网络共享。Use the /log parameter to redirect the log file to another location, including a network share.

运行该工具Run the tool

要运行该工具,请执行以下操作:To run the tool:

  1. 以管理员身份打开命令提示符。Open a command prompt as an administrator. 将目录更改为包含 ContentLibraryCleanup.exe 的文件夹 。Change directory to the folder that contains ContentLibraryCleanup.exe.

  2. 输入命令行,其中包含必需的命令行参数和要使用的任何可选参数。Enter a command line that includes the required command-line parameters, and any optional parameters you want to use.

命令行参数Command-line parameters

按任何顺序使用命令行参数。Use these command-line parameters in any order.

必需参数Required parameters

参数Parameter 详细信息Details
/dp <distribution point FQDN> 指定待清理分发点的完全限定的域名 (FQDN)。Specify the fully qualified domain name (FQDN) of the distribution point to clean.
/ps <primary site FQDN> 仅在从辅助站点的分发点清除内容时需要 。Required only when cleaning content from a distribution point at a secondary site. 该工具连接到父主站点,针对 SMS 提供程序运行查询。The tool connects to the parent primary site to run queries against the SMS Provider. 工具通过这些查询确定分发点上应有的内容。These queries let the tool determine what content should be on the distribution point. 然后,它可以识别要删除的孤立内容。It can then identify the orphaned content to remove. 必须为辅助站点上的分发点创建与父主站点的连接,因为所需的详细信息无法直接从辅助站点获取。This connection to the parent primary site must be made for distribution points at a secondary site because the required details aren't available directly from the secondary site.
/sc <primary site code> 仅在从辅助站点的分发点清除内容时需要 。Required only when cleaning content from a distribution point at a secondary site. 指定父主站点的站点代码。Specify the site code of the parent primary site.

例如:扫描并记录要删除的内容(假设)Example: Scan and log what content it would delete (what-if)

ContentLibraryCleanup.exe /dp server1.contoso.com

例如:扫描并记录辅助站点上分发点的内容Example: Scan and log content for a DP at a secondary site

ContentLibraryCleanup.exe /dp server1.contoso.com /ps siteserver1.contoso.com /sc ABC

可选参数Optional parameters

参数Parameter 详细信息Details
/delete 准备好从分发点删除内容时,请使用此参数。Use this parameter when you're ready to delete content from the distribution point. 它会在删除内容之前提示用户。It prompts you before it deletes content.

如果不使用此参数,工具会记录有关待删除内容的结果。When you don't use this parameter, the tool logs results about what content it would delete. 如果没有此参数,它实际上不会从分发点删除任何内容。Without this parameter, it doesn't actually delete any content from the distribution point.
/q 此参数以安静模式运行工具,该模式禁止所有提示。This parameter runs the tool in a quiet mode that suppresses all prompts. 这些提示包括删除内容的时间。These prompts include when it deletes content. 它也不会自动打开日志文件。It also doesn't automatically open the log file.
/ps <primary site FQDN> 仅在从主站点的分发点清除内容时可选。Optional only when cleaning content from a distribution point at a primary site. 指定分发点所属主站点的 FQDN。Specify the FQDN of the primary site that the distribution point belongs to.
/sc <primary site code> 仅在从主站点的分发点清除内容时可选。Optional only when cleaning content from a distribution point at a primary site. 指定分发点所属主站点的站点代码。Specify the site code of the primary site that the distribution point belongs to.
/log <log file directory> 指定该工具写入日志文件的位置。Specify the location where the tool writes the log file. 此位置可以是本地驱动器,也可以是网络共享。This location can be a local drive or a network share.

如果不使用此参数,工具会将日志文件放在用户临时目录中(位于运行工具的计算机上)。When you don't use this parameter, the tool places the log file in the user's temp directory on the computer where the tool runs.

例如:删除内容Example: Delete content

ContentLibraryCleanup.exe /dp server1.contoso.com /delete

例如:无提示情况下删除内容Example: Delete content without prompts

ContentLibraryCleanup.exe /q /dp server1.contoso.com /delete

例如:记录到本地驱动器Example: Log to local drive

ContentLibraryCleanup.exe /dp server1.contoso.com /log C:\Users\Administrator\Desktop

例如:记录到网络共享Example: Log to network share

ContentLibraryCleanup.exe /dp server1.contoso.com /log \\server\share

已知问题Known issue

当任何包或部署失败或正在进行时,该工具可能会返回以下错误:System.InvalidOperationException: This content library cannot be cleaned up right now because package <packageID> is not fully installed.When any package or deployment has failed, or is in progress, the tool might return the following error: System.InvalidOperationException: This content library cannot be cleaned up right now because package <packageID> is not fully installed.

此问题没有任何解决方法。There's no workaround for this issue. 当内容正在进行处理或部署失败时,该工具无法可靠地识别孤立文件。The tool can't reliably identify orphaned files when content is in progress or has failed to deploy. 必须先解决该问题,工具才会允许清理内容。The tool won't allow you to clean up content until you resolve that issue.