默认情况下,Compute Engine 会在高于 v20190714 的 Windows Server 映像公开版本上安装诊断工具。如果您的 Windows Server 映像版本低于 v20190714,或者您使用的是自定义映像,请使用 googet install google-compute-engine-diagnostics 命令安装该工具。
如果您尚未设置身份验证,请进行设置。身份验证是通过其进行身份验证以访问 Google Cloud 服务和 API 的过程。如需从本地开发环境运行代码或示例,您可以通过选择以下选项之一向 Compute Engine 进行身份验证:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and
APIs, you don't need to set up authentication.
gcloud
After installing the Google Cloud CLI,
initialize it by running the following command:
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-29。"],[[["\u003cp\u003eThis document describes a diagnostic tool for collecting information from Windows virtual machine (VM) instances to aid in troubleshooting before contacting support.\u003c/p\u003e\n"],["\u003cp\u003eThe diagnostic tool collects data related to disks, events, networks, programs, and system configurations, storing the information within the user's project for 10 days in a Cloud Storage bucket that defaults to private access.\u003c/p\u003e\n"],["\u003cp\u003eBefore sharing any collected diagnostic data with Google Support, users should review the information for any confidential or personally identifiable data and remove or mask it as necessary.\u003c/p\u003e\n"],["\u003cp\u003eThe tool is installed by default on Windows Server images later than \u003ccode\u003ev20190714\u003c/code\u003e; otherwise, it can be installed using the \u003ccode\u003egooget\u003c/code\u003e command, and diagnostic data can be exported remotely using the Google Cloud CLI.\u003c/p\u003e\n"],["\u003cp\u003eCollecting diagnostic data requires the \u003ccode\u003eiam.serviceAccountTokenCreator\u003c/code\u003e role, which can be granted to specific email addresses within a project using a provided gcloud command.\u003c/p\u003e\n"]]],[],null,["# Collecting diagnostic information\n\nWindows\n\n*** ** * ** ***\n\nThis document describes how to collect information about a virtual machine (VM)\ninstance by using a diagnostic tool. Use the information that the tools collects\nto help with basic troubleshooting before contacting\n[Support](/compute/docs/support).\n\nThe tool does the following:\n\n- Collects information only from the VM that you specify.\n\n- Stores the information only in your project.\n\n- Stores the information for 10 days in a [Cloud Storage\n bucket](/storage/docs/creating-buckets), which, by default, only you can access.\n\nBefore sharing the collected information with Google Support, do the following:\n\n1. Review the information for confidential or personally identifiable\n information (PII).\n\n2. Delete or mask the information as necessary.\n\nDiagnostic information collected from the VM\n--------------------------------------------\n\nThis diagnostic tool collects information about the following:\n\n- **Disks**:\n\n - [Windows Management Instrumentation\n (WMI)](https://docs.microsoft.com/en-us/windows/win32/wmisdk/wmi-start-page) object information about [disks](https://learn.microsoft.com/en-us/windows-hardware/drivers/storage/msft-disk), [partitions](https://learn.microsoft.com/en-us/windows-hardware/drivers/storage/msft-partition), and [volumes](https://learn.microsoft.com/en-us/windows-hardware/drivers/storage/msft-volume)\n- **Events**:\n\n - [Windows Events](https://docs.microsoft.com/en-us/windows/win32/events/windows-events?redirectedfrom=MSDN), including application events and system events\n- **Networks**:\n\n - WMI object information about [firewall rules](https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/jj676843(v%3Dvs.85)), and output from [ipconfig](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/ipconfig), [netstat](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/netstat), [nslookup](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup), [ping](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/ping), [route](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/route_ws2008), and [tracert](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/tracert)\n- **Programs**:\n\n - WMI object information about [processes](https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-process), [scheduled tasks](https://docs.microsoft.com/en-us/powershell/module/scheduledtasks/get-scheduledtask?view=win10-ps), [services](https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-service), and [Google Kubernetes Engine (GKE)](https://cloud.google.com/kubernetes-engine/docs/concepts/windows-server-gke)\n- **System**:\n\n - WMI object information about [users](https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-useraccount), Remote Desktop Protocol (RDP) settings by using [this script](https://github.com/GoogleCloudPlatform/compute-image-tools/blob/master/cli_tools/diagnostics/rdp_status.ps1), and output from [bcdedit](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/bcdedit), [driverquery](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/driverquery), [msinfo32](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/msinfo32), [pnputil](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/pnputil), and [systeminfo](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/systeminfo), and [memory dump](https://docs.microsoft.com/en-us/troubleshoot/windows-server/performance/memory-dump-file-options) logs\n\nFor detailed information about how Compute Engine collects this\ninformation, see the [public repository](https://github.com/GoogleCloudPlatform/compute-image-tools/tree/master/cli_tools/diagnostics).\n\nLimitations\n-----------\n\n- You can only collect diagnostic information from VMs created based on Windows Server.\n\nBefore you begin\n----------------\n\n- Compute Engine installs the diagnostic tool by default on public versions of Windows Server images later than `v20190714`. Otherwise, if your Windows Server image version is earlier than `v20190714`, or you are using a custom image, install the tool by using the `googet install google-compute-engine-diagnostics` command.\n- If you haven't already, set up [authentication](/compute/docs/authentication). Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:\n\n Select the tab for how you plan to use the samples on this page: \n\n ### Console\n\n\n When you use the Google Cloud console to access Google Cloud services and\n APIs, you don't need to set up authentication.\n\n ### gcloud\n\n 1.\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n After installation,\n [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command:\n\n ```bash\n gcloud init\n ```\n\n\n If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n | **Note:** If you installed the gcloud CLI previously, make sure you have the latest version by running `gcloud components update`.\n 2. [Set a default region and zone](/compute/docs/gcloud-compute#set_default_zone_and_region_in_your_local_client).\n\n ### REST\n\n\n To use the REST API samples on this page in a local development environment, you use the\n credentials you provide to the gcloud CLI.\n 1. [Install](/sdk/docs/install) the Google Cloud CLI. After installation, [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command: \n\n ```bash\n gcloud init\n ```\n 2. If you're using an external identity provider (IdP), you must first [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n\n For more information, see\n [Authenticate for using REST](/docs/authentication/rest)\n in the Google Cloud authentication documentation.\n\nCollecting diagnostic information from a VM\n-------------------------------------------\n\nRun the diagnostic tool either directly from the VM, or remotely, by using the\nGoogle Cloud CLI. On Windows-based VMs, find the diagnostic tool in the\n`C:\\Program Files\\Google\\Compute Engine\\diagnostics` directory.\n\n#### Permissions required for this task\n\nTo perform this task, you must have the following [permissions](/iam/docs/overview#permissions):\n\n- `roles/iam.serviceAccountTokenCreator` on the project\n\n### gcloud\n\n1. Grant the `iam.serviceAccountTokenCreator` role on the project:\n\n ```\n gcloud projects add-iam-policy-binding PROJECT_ID \\\n --member user:EMAIL \\\n --role roles/iam.serviceAccountTokenCreator\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the project ID\n - \u003cvar translate=\"no\"\u003eEMAIL\u003c/var\u003e: the email address to grant the `iam.serviceAccountTokenCreator` role\n2. Export the diagnostic information as an object to a Cloud Storage\n bucket.\n\n ```\n gcloud compute diagnose export-logs VM_NAME \\\n [--collect-process-traces]\n ```\n\n The optional `--collect-process-traces` flag specifies\n whether the diagnostic tool collects a 10 minute trace of the running\n system, which includes CPU, disk, file, and network activity. On\n Windows-based VMs, this uses the [Windows Performance\n Recorder](https://docs.microsoft.com/en-us/windows-hardware/test/wpt/windows-performance-recorder).\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e: name of the VM to collect diagnostic information from\n3. The log exporting process might take a few minutes to complete. View the\n status by using the [`gcloud compute instances get-serial-port-output`\n command](/sdk/gcloud/reference/compute/instances/get-serial-port-output).\n\n4. Compute Engine formats the name of the bucket containing the\n diagnostic information as\n `diagnostic_logs_project_`\u003cvar translate=\"no\"\u003ePROJECT_NUMBER\u003c/var\u003e.\n View or download the bucket by using the\n [gcloud CLI](/sdk/gcloud/reference/storage), or, in the\n Google Cloud console, from the **Cloud Storage** page:\n\n [Go to Storage](https://console.cloud.google.com/storage)\n\nWhat's next\n-----------\n\n- Learn how to [capture screenshots from VMs](/compute/docs/instances/capturing-vm-screenshots).\n\n- Learn how to [Troubleshoot Windows\n instances](/compute/docs/troubleshooting/troubleshooting-windows).\n\n- Learn how to [Troubleshoot RDP](/compute/docs/troubleshooting/troubleshooting-rdp)."]]