電腦分析記錄收集器Desktop Analytics log collector

自 Configuration Manager 1906 版開始,使用 Configuration Manager 安裝目錄中的 DesktopAnalyticsLogsCollector.ps1 工具,以協助針對電腦分析裝置註冊的問題進行疑難排解。Starting in Configuration Manager version 1906, use the DesktopAnalyticsLogsCollector.ps1 tool from the Configuration Manager install directory to help troubleshoot Desktop Analytics device enrollment issues. 它會執行一些基本的疑難排解步驟,並將相關記錄收集到單一工作目錄中。It runs some basic troubleshooting steps and collects the relevant logs into a single working directory. 您可以與 Microsoft 支援服務共用此內容。You can share this content with Microsoft support.

先決條件Prerequisites

使用方式Usage

從 Configuration Manager 安裝內容取得指令碼:SMSSETUP\TOOLS\DesktopAnalyticsLogsCollector\DesktopAnalyticsLogsCollector.ps1Get the script from the Configuration Manager installation content: SMSSETUP\TOOLS\DesktopAnalyticsLogsCollector\DesktopAnalyticsLogsCollector.ps1

DesktopAnalyticsLogsCollector.ps1
    [-LogPath] <String>
    [-LogMode] <Int16>
    [-CollectNetTrace] <Int16>
    [-CollectUTCTrace] <Int16>

參數Parameters

-LogPath

指定放置記錄檔和其他輸出檔案的本機或 UNC 路徑。Specifies a local or UNC path to put the log and other output files.

Values:

  • 本機路徑 (長度上限 = 130),例如:c:\myfolderLocal path (maximum length = 130), for example: c:\myfolder

  • UNC 路徑 (長度上限 = 130),例如:\\myserver\myfolderUNC path (maximum length = 130), for example: \\myserver\myfolder

類型:字串Type: String

位置:1Position: 1

預設值$Env:SystemDrive\M365AnalyticsLogs (當此參數為 null、空值或空白字元時,指令碼會在系統磁碟機下建立 M365AnalyticsLogs 資料夾。)Default value: $Env:SystemDrive\M365AnalyticsLogs (When this parameter is null, empty, or white space, the script creates the M365AnalyticsLogs folder under the system drive.)

-LogMode

指定記錄檔的詳細資訊層級。Specifies the verbose level of the logs.

Values:

  • 0:僅將指令碼訊息記錄到 PowerShell 命令視窗。0: Log script messages to PowerShell command window only.

  • 1:將指令碼訊息同時記錄到輸出資料夾下的記錄檔和 PowerShell 命令視窗。1: Log script messages to both log file under the output folder and PowerShell command window.

  • 2:僅將指令碼訊息記錄到輸出資料夾下的記錄檔。2: Log script messages to log file under the output folder only.

類型:Int16Type: Int16

位置:2Position: 2

預設值1 (將指令碼訊息同時記錄到記錄檔和 PowerShell 命令視窗。)Default value: 1 (Log script messages to both log file and PowerShell command window.)

-CollectNetTrace

指定指令碼是否收集網路追蹤。Specifies whether the script collects the network trace.

Values:

  • 0:不啟用網路追蹤。0: Don't enable the network trace.

  • 1 (任何非零的整數值):啟用網路追蹤並收集結果。1 (any non-zero integer value): Enable network trace and collect results.

類型:Int16Type: Int16

位置:3Position: 3

預設值0 (不啟用網路追蹤)Default value: 0 (Don't enable the network trace)

-CollectUTCTrace

指定指令碼是否收集 Windows UTC 追蹤並執行連線能力診斷。Specifies whether the script collects the Windows UTC trace and run connectivity diagnosis.

Values:

  • 0:不啟用 UTC 追蹤,或不執行連線能力診斷。0: Don't enable the UTC trace or run connectivity diagnosis.

  • 1 (任何非零的整數值):啟用 UTC 追蹤、執行連線能力診斷,以及收集結果。1 (any non-zero integer value): Enable the UTC trace, run connectivity diagnosis, and collect results.

類型:Int16Type: Int16

位置:4Position: 4

預設值0 (不啟用 UTC 追蹤,或不執行連線能力診斷)Default value: 0 (Don't enable the UTC trace or run connectivity diagnosis)

輸出Output

指令碼會在指定的路徑下建立「工作資料夾」 。The script creates a working folder under the specified path. 例如,M365AnalyticsLogs_yy_MM_dd_HH_mm_ssFor example, M365AnalyticsLogs_yy_MM_dd_HH_mm_ss. 它會將所有輸出檔案放入此工作資料夾。It puts all its output files into this working folder.

如果啟用指令碼寫入「記錄檔」 ,即會在工作資料夾中產生一個記錄檔。If you enable the script to write to a log file, it generates one in the working folder. 例如,M365AnalyticsLogs_ yy_MM_dd_HH_mm_ss.txtFor example, M365AnalyticsLogs_ yy_MM_dd_HH_mm_ss.txt.

指令碼也會在工作資料夾內產生其他的「診斷檔案」 。The script also generates other diagnostic files in the working folder. 例如:For example:

  • installedKBs.txt:安裝在裝置上的 Windows 更新清單installedKBs.txt: a list of Windows updates installed on the device
  • appcompat:應用程式相容性資料appcompat: application compatibility data
  • Reg*.txt:具有自 Windows 登錄所匯出資料的系列檔案Reg*.txt: a series of files with exported data from the Windows Registry

範例Examples

範例 1:使用預設值透過 PowerShell 命令視窗執行指令碼Example 1: Run script via PowerShell command window with default values

.\DesktopAnalyticsLogsCollector.ps1

範例 2:使用指定的參數透過 PowerShell 命令視窗執行指令碼Example 2: Run script via PowerShell command window with specified parameters

.\DesktopAnalyticsLogsCollector.ps1 -LogPath "c:\testABC" -LogMode 0 -CollectNetTrace 0 -CollectUTCTrace 0

範例 3:使用正確位置的指定參數透過 PowerShell 命令視窗執行指令碼Example 3: Run script via PowerShell command window with specified parameters in position

.\DesktopAnalyticsLogsCollector.ps1 "c:\testABC" 2 0 0

範例 4:使用指定的參數和詳細資訊訊息透過 PowerShell 命令視窗執行指令碼Example 4: Run script via PowerShell command window with specified parameter and verbose messages

.\DesktopAnalyticsLogsCollector.ps1 -LogMode 1 -Verbose

範例 5:透過 Configuration Manager 指令碼部署指令碼Example 5: Deploy script via Configuration Manager Scripts

如需詳細資訊,請參閱從 Configuration Manager 主控台建立及執行 PowerShell 指令碼For more information, see Create and run PowerShell scripts from the Configuration Manager console.

DesktopAnalyticsLogsCollector.ps1 是由 Microsoft 以數位方式簽署。DesktopAnalyticsLogsCollector.ps1 is digitally signed by Microsoft. 您可能需要將其 Microsoft 程式碼簽署憑證新增為目標裝置上的受信任發行者。You may need to add its Microsoft code signing certificate as a Trusted Publisher on the target device.

  1. 在 Windows 檔案總管中開啟指令碼的屬性。Open the properties of the script in Windows Explorer. 切換至 [數位簽章] 索引標籤並選取 [詳細資料] 。Switch to the Digital Signatures tab and select Details.

  2. 在 [一般] 索引標籤上,選取 [檢視憑證] 。On the General tab, select View Certificate.

    注意

    若要透過其他機制散發憑證,請先將憑證匯出至檔案。To distribute the certificate via other mechanisms, first export the certificate to a file. 移至 [詳細資料] 索引標籤並選取 [複製到檔案] 。Go to the Details tab, and select Copy to File.

  3. 選取 [安裝憑證] 。Select Install Certificate. 匯入憑證,將它放置在受信任的發行者存放區。Import the certificate, placing it in the Trusted Publishers store.

請參閱See also