擷取 VM 螢幕截圖


本頁面說明如何使用 VM 螢幕截圖工具,擷取虛擬機器 (VM) 執行個體的螢幕截圖。

擷取 VM 的螢幕截圖有助於排除無法存取的 VM 問題。舉例來說,如果 VM 正在開機或磁碟映像檔已損毀,您可能無法存取 VM。

以 Windows 為基礎的作業系統

您可以透過 VM 螢幕截圖,瞭解是否已成功啟動執行個體,藉此排解 Windows VM 的 RDP 連線失敗問題。如要瞭解如何排除遠端桌面通訊協定連線問題,請參閱「遠端桌面通訊協定疑難排解」。

遠端桌面用戶端的隱私權考量

VM 螢幕截圖工具會使用 VM 的顯示卡,透過遠端桌面用戶端擷取本機主控台工作階段的螢幕截圖。透過本機控制台工作階段擷取螢幕截圖,可能會擷取使用者電腦或瀏覽器中的敏感資訊。

如果您擔心螢幕截圖會洩漏敏感資訊,請按照下列方式設定相應的遠端桌面用戶端,以便不使用本機主控台工作階段:

在與 Google 支援團隊分享螢幕截圖之前,請務必檢查是否含有任何機密資訊。

事前準備

  • 在 VM 上啟用虛擬顯示器
  • 如果尚未設定,請先設定驗證機制。驗證是指驗證身分,以便存取 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

    1. After installing the Google Cloud CLI, initialize it by running the following command:

      gcloud init

      If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

    2. Set a default region and zone.

    REST

    To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.

      After installing the Google Cloud CLI, initialize it by running the following command:

      gcloud init

      If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

    For more information, see Authenticate for using REST in the Google Cloud authentication documentation.

限制

  • 執行個體必須處於 RUNNING 生命週期狀態

  • 擷取螢幕截圖的最高頻率為每秒 20 張,這是 API 傳送頻率上限

  • 在進行螢幕截圖時,無法啟動另一個螢幕截圖。

  • 一次只能擷取一張螢幕截圖。

擷取 VM 的螢幕截圖

請按照下列程序,擷取 VM 的螢幕截圖。

主控台

  1. 前往 Google Cloud 控制台的「VM instances」(VM 執行個體) 頁面

    前往 VM 執行個體

  2. 在「VM 執行個體」頁面中,按一下要擷取螢幕截圖的 VM 執行個體名稱。

  3. 在「VM 執行個體詳細資料」頁面上,按一下「螢幕截圖」分頁標籤。

  4. 按一下「Refresh」,即可產生 VM 的螢幕截圖。如果您尚未啟用虛擬螢幕,Google Cloud 控制台就不會顯示螢幕截圖。

gcloud

使用 gcloud compute instances get-screenshot 指令,擷取 VM 的螢幕截圖:

gcloud compute instances get-screenshot VM_NAME \
  --destination=JPEG_FILENAME \
  --zone=ZONE

更改下列內容:

  • VM_NAME:要擷取螢幕截圖的 VM 名稱。

  • JPEG_FILENAME:螢幕截圖輸出結果的 JPEG 選用檔案名稱。如果未指定檔案名稱,系統會將原始 JPEG 資料傳送至標準輸出 (stdout)。

  • ZONE:要擷取螢幕截圖的 VM 區域。

REST

使用 Compute Engine API 時,請使用 instances.getScreenshot 要求擷取 VM 的螢幕截圖:

GET https://compute.googleapis.com/compute/v1/projects/PROJECT/zo
nes/ZONE/instances/VM_NAME/screenshot

更改下列內容:

  • PROJECT:包含要擷取螢幕截圖的 VM 專案 ID。

  • ZONE:包含專案的區域。

  • VM_NAME:要擷取螢幕截圖的 VM 名稱。

VM 螢幕截圖範例

Compute Engine UEFI 載入啟動管理工具

下圖顯示在開機管理員載入期間無法使用的 Windows Server VM:

UEFI 載入啟動管理工具

Windows Server 2016 Datacenter 執行更新

下列螢幕截圖顯示在完成更新時無法使用的 Windows Server 2016 VM:

Windows Server 2016 Datacenter 執行更新。

Windows Server 2016 載入系統服務

下圖顯示在載入系統服務時無法使用的 Windows Server 2016 VM:

Windows Server 2016 載入系統服務。

Windows Server 2016 Datacenter 的登入畫面

下列螢幕截圖顯示已完成啟動並可登入的 Windows Server 2016 VM:

Windows Server 2016 Datacenter 的登入畫面。

Windows Server 2019 Core 的 Sysprep 程序

下圖顯示 Windows Server 2019 Core VM 執行個體的 sysprep 程序

Windows Server 2019 Core 的 Sysprep 程序。

Windows Server 2016 Datacenter 的藍色畫面錯誤

以下螢幕截圖顯示 Windows Server 2016 Datacenter VM 例項的藍色畫面錯誤:

Windows Server 2016 Datacenter 的藍色畫面。

後續步驟