本文說明如何連線至 Windows Special Administrative Console (SAC)。SAC 會使用序列埠連線至 Windows 虛擬機器 (VM) 執行個體,且不依賴網路連線,因此有助於排解 Windows VM 執行個體的問題或進行復原。連線至 VM 的序列埠主控台並使用 SAC,即可中斷 VM 的開機程序,或存取 CMD 或 PowerShell 終端機進行疑難排解。如要使用遠端桌面進行一般用途 (而非疑難排解),請使用 RDP 連線至 Windows VM。
事前準備
如要使用互動式序列主控台連線至 VM 的 SAC,請先啟用 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
安裝 Google Cloud CLI。
安裝完成後,執行下列指令初始化 Google Cloud CLI:
按一下「Connect to serial console」(連線至序列主控台),開啟互動式控制台。
互動式序列主控台隨即開啟,看到下列輸出內容時,表示已可使用:
Computer is booting, SAC started and initialized.
Use the "ch -?" command for information about using channels.
Use the "?" command for general help.
SAC>
Computer is booting, SAC started and initialized.
Use the "ch -?" command for information about using channels.
Use the "?" command for general help.
SAC>
SAC>cmd
The Command Prompt session was successfully launched.
SAC>
EVENT: A new channel has been created. Use "ch -?" for channel help.
Channel: Cmd0001
SAC>
使用 ch -sn CHANNEL_NAME 指令,然後按一下 Enter 鍵。
ch -sn CHANNEL_NAME
將 CHANNEL_NAME 替換成您在上一個步驟中建立的管道名稱。
輸出結果會與下列內容相似:
Name: Cmd0001
Description: Command
Type: VT-UTF8
Channel GUID: 28de7392-5413-11ea-bb03-c9656a2ed613
Application Type GUID: 63d02271-8aa4-11d5-bccf-00b0d014a2d0
Press <esc><tab> for next channel.
Press <esc><tab>0 to return to the SAC channel.
Use any other key to view this channel.
按下空格鍵,然後使用系統上註冊的本機憑證登入。
Please enter login credentials.
Username: USERNAME
Domain: DOMAIN (leave blank if no domain)
Password: PASSWORD
連線後,您就能存取命令提示字元殼層。
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.
C:\Windows\system32>
選用:如要輸入 Powershell 提示,請輸入 powershell.exe,然後按下 Enter 鍵。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-03 (世界標準時間)。"],[[["\u003cp\u003eThis document details how to connect to the Windows Special Administrative Console (SAC) via a serial port, enabling troubleshooting and recovery of Windows virtual machine (VM) instances without network reliance.\u003c/p\u003e\n"],["\u003cp\u003eBefore connecting, ensure you enable interactive access for your VM and set up authentication as required for access to Google Cloud services and APIs.\u003c/p\u003e\n"],["\u003cp\u003eYou can connect to the serial console through the Google Cloud console or using the \u003ccode\u003egcloud\u003c/code\u003e command-line tool, both of which will display a prompt if successfully connected.\u003c/p\u003e\n"],["\u003cp\u003eWithin the SAC, you can access a Command Prompt by typing \u003ccode\u003ecmd\u003c/code\u003e and then use channel commands to interact, or optionally access a PowerShell prompt by typing \u003ccode\u003epowershell.exe\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe SAC is a valuable tool for accessing a CMD or PowerShell terminal for troubleshooting, or interrupting a VM's boot process, but it does not support IP based access restrictions.\u003c/p\u003e\n"]]],[],null,["Windows\n\n*** ** * ** ***\n\nThis document describes how to connect to the\n[Windows Special Administrative Console](https://technet.microsoft.com/en-us/library/cc787940) (SAC).\nThe SAC uses a serial port connection to a Windows virtual machine (VM) instance\nand doesn't rely on network connectivity, which can help troubleshoot or recover\na Windows VM instance. By connecting to the VM's serial console and using the SAC,\nyou can interrupt the VM's boot process or gain access to a CMD or PowerShell\nterminal to perform troubleshooting. For a general purpose remote desktop\nexperience other than troubleshooting,\n[connect to Windows VMs using RDP](/compute/docs/instances/connecting-to-windows).\n\nBefore you begin\n\n- Before you can connect to your VM's SAC by using the interactive serial console, enable interactive access for your VM. For more information, see [Enabling interactive access on the serial console](/compute/docs/troubleshooting/troubleshooting-using-serial-console#enabling_interactive_access_on_the_serial_console).\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 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| **Caution:** The interactive serial console does not support IP-based access restrictions such as IP-based include lists or exclude lists. If you enable the interactive serial console on an instance, anyone from any IP address is able to connect if they know a local username, project ID, zone, and instance name.\n\nConnect to the Serial Console\n\nTo connect to your Windows instance using an interactive serial console,\ncomplete the steps in one of the following tabs.\n\nPermissions required for this task\n\nTo perform this task, you must have the following\n[permissions](/iam/docs/overview#permissions):\n\n\n- `compute.instances.setMetadata` on the VM if enabling interactive access on a specific VM\n- `compute.projects.setCommonInstanceMetadata` on the project, if enabling interactive access for all VMs in the project\n- `iam.serviceAccountUser` role on the instance's service account \n\nConsole\n\n1. In the Google Cloud console, go to the **VM instances** page.\n\n [Go to VM instances](https://console.cloud.google.com/compute/instances)\n2. Click the name of the VM you want to connect to.\n\n3. Click **Connect to serial console** to open the interactive\n console.\n\nThe interactive serial console opens. It's ready to use when you see the\nfollowing output: \n\n```\nComputer is booting, SAC started and initialized.\n\nUse the \"ch -?\" command for information about using channels.\nUse the \"?\" command for general help.\n\nSAC\u003e\n```\n\nIf the interactive serial console is a blank screen with a blinking cursor,\nit is likely because the [Emergency Management Services](https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/boot-parameters-to-enable-ems-redirection)\nare off.\nSee [troubleshooting interactive serial console](/compute/docs/troubleshooting/troubleshooting-windows#troubleshooting-interactive-serial-console)\nto learn how to resolve this issue.\n\ngcloud\n\nUse the [`gcloud compute connect-to-serial-port`\ncommand](/sdk/gcloud/reference/compute/connect-to-serial-port) to connect to\nVM instances that have serial port access enabled: \n\n```\ngcloud compute connect-to-serial-port VM_NAME \\\n --port=2 \\\n --zone=ZONE \\\n --project=PROJECT_ID\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the ID of the project that contains the VM\n- \u003cvar translate=\"no\"\u003eZONE\u003c/var\u003e: the name of the zone in which the VM is located\n- \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e: the name of the VM\n\nThe interactive serial console opens. It is ready to use when you see the\nfollowing output: \n\n```\nComputer is booting, SAC started and initialized.\n\nUse the \"ch -?\" command for information about using channels.\nUse the \"?\" command for general help.\n\nSAC\u003e\n```\n\nIf the interactive serial console is a blank screen with a blinking cursor,\nit is likely because the [Emergency Management Services](https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/boot-parameters-to-enable-ems-redirection)\nare off.\nSee [troubleshooting interactive serial console](/compute/docs/troubleshooting/troubleshooting-windows#troubleshooting-interactive-serial-console)\nto learn how to resolve this issue.\n\nFor information about using the interactive serial console, see the Microsoft\n[SAC Commands documentation](https://technet.microsoft.com/en-us/library/cc787940#sac-commands).\n\nOpen Command Prompt in Windows SAC\n\nTo open Command Prompt in the SAC, do the following:\n\n1. Type `cmd`, then press **Enter**. You see the following output:\n\n ```\n SAC\u003ecmd\n The Command Prompt session was successfully launched.\n SAC\u003e\n EVENT: A new channel has been created. Use \"ch -?\" for channel help.\n Channel: Cmd0001\n SAC\u003e\n ```\n2. Use the `ch -sn `\u003cvar translate=\"no\"\u003eCHANNEL_NAME\u003c/var\u003e command, then press\n **Enter**.\n\n ```\n ch -sn CHANNEL_NAME\n ```\n\n Replace \u003cvar translate=\"no\"\u003eCHANNEL_NAME\u003c/var\u003e with the name of the\n channel you created in the previous step.\n\n The output is similar to the following: \n\n ```\n Name: Cmd0001\n Description: Command\n Type: VT-UTF8\n Channel GUID: 28de7392-5413-11ea-bb03-c9656a2ed613\n Application Type GUID: 63d02271-8aa4-11d5-bccf-00b0d014a2d0\n\n Press \u003cesc\u003e\u003ctab\u003e for next channel.\n Press \u003cesc\u003e\u003ctab\u003e0 to return to the SAC channel.\n Use any other key to view this channel.\n ```\n3. Press **Space**, then login with the local credentials registered on the\n system.\n\n ```\n Please enter login credentials.\n Username: USERNAME\n Domain: DOMAIN (leave blank if no domain)\n Password: PASSWORD\n ```\n | **Note:** If you are unsure of the credentials, you might be able to [create or\n | reset the password](/compute/docs/instances/windows/creating-passwords-for-windows-instances).\n\n Once connected, you have access to a Command Prompt shell. \n\n ```\n Microsoft Windows [Version 10.0.14393]\n (c) 2016 Microsoft Corporation. All rights reserved.\n\n C:\\Windows\\system32\u003e\n ```\n4. Optional: To enter a Powershell prompt, type `powershell.exe`, then press\n **Enter**.\n\n | **Note:** Pasting into the SAC Powershell terminal might result in repeated characters in the pasted text. You can prevent this on a per-session basis by issuing the `Remove-Module PSReadLine` command in your terminal.\n\nWhat's next\n\n- Learn how to [connect to Windows VMs using RDP](/compute/docs/instances/connecting-to-windows)\n- Learn how to [troubleshoot Interactive Serial Console](/compute/docs/troubleshooting/troubleshooting-windows#troubleshooting-interactive-serial-console)."]]