

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 使用 EC2Rescue CLI 來疑難排解受損的 Windows 執行個體
<a name="ec2rw-cli"></a>

EC2Rescue for Windows Server 命令列界面 (CLI) 讓您透過編寫程式的方式執行 EC2Rescue for Windows Server 外掛程式 (稱為「動作」)。

EC2Rescue for Windows Server 工具有兩種執行模式：
+ **/online**—這可讓您對 EC2Rescue for Windows Server 安裝所在的執行個體採取動作，例如收集日誌檔案。
+ **/offline:<device\$1id>**—這可讓您對連線到不同 Amazon EC2 Windows 執行個體的離線根磁碟區採取動作，此執行個體已安裝 EC2Rescue for Windows Server。

將 [EC2Rescue for Windows Server](https://s3.amazonaws.com/ec2rescue/windows/EC2Rescue_latest.zip?x-download-source=docs) 工具下載到您的 Windows 執行個體並解壓縮檔案。您可以使用下列命令來檢視說明檔案：

```
EC2RescueCmd.exe /help
```

EC2Rescue for Windows Server 會議主持人可在 Amazon EC2 Windows 執行個體上執行下列動作：
+ [收集動作](#ec2rw-collect)
+ [救援動作](#ec2rw-rescue)
+ [還原動作](#ec2rw-restore)

## 收集動作
<a name="ec2rw-collect"></a>

**注意**  
您可收集所有日誌、完整的日誌群組，或群組內的個別日誌。

EC2Rescue for Windows Server 可從**作用中和離線的執行個體**收集下列資料。


| 日誌群組 | 可用日誌 | 描述 | 
| --- | --- | --- | 
| all |  | 收集所有可用的日誌。 | 
| eventlog |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/ec2rw-cli.html)  | 收集應用程式、系統和 EC2Config 事件日誌。 | 
| memory-dump |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/ec2rw-cli.html)  | 收集執行個體上所有的記憶體傾印檔案。 | 
| ec2config |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/ec2rw-cli.html)  | 收集 EC2Config 服務產生的日誌檔案。 | 
| ec2launch |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/ec2rw-cli.html)  | 收集 EC2Launch 指令碼產生的日誌檔案。 | 
| ssm-agent |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/ec2rw-cli.html)  | 收集 SSM Agent 和修補程式管理員日誌產生的日誌檔案。 | 
| sysprep | 'Log Files' | 收集 Windows 系統準備工具產生的日誌檔案。 | 
| driver-setup |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/ec2rw-cli.html)  | 收集 Windows SetupAPI 日誌 (setupapi.dev.log 和 setupapi.setup.log)。 | 
| registry |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/ec2rw-cli.html)  | 收集 SYSTEM 和 SOFTWARE Hive。 | 
| egpu |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/ec2rw-cli.html)  | 收集與 Elastic GPU 相關的事件日誌。 | 
| boot-config | 'BCDEDIT Output' | 收集 HKEY\$1LOCAL\$1MACHINE\$1BCD00000000 Hive。 | 
| windows-update | 'Log Files' | 收集 Windows Update 產生的日誌檔案。 在 Windows Server 2016 年及更新版本中，日誌會以 Event Tracing for Windows (ETW) 格式收集。 | 
| cloudendure |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/ec2rw-cli.html)  | 收集與 CloudEndure 代理程式相關的日誌檔案。 | 

EC2Rescue for Windows Server 可從**作用中執行個體**收集下列其他資料。


| 日誌群組 | 可用日誌 | 描述 | 
| --- | --- | --- | 
| system-info | 'MSInfo32 Output' | 收集 MSInfo32。 | 
| gpresult | 'GPResult Output' |  收集 Group Policy (群組政策) 報告。  | 

以下為可用的選項：
+ **/output:<outputFilePath>** ‐ 需要目標檔案路徑位置，才能以 zip 格式儲存收集的日誌檔案。
+ **/no-offline** - 離線模式中使用的選用屬性。完成動作後不會將磁碟區設為離線。
+ **/no-fix-signature** ‐ 離線模式中使用的選用屬性。完成動作後不會修正可能的磁碟簽章衝突。

### 範例
<a name="ec2rw-collect-examples"></a>

以下是使用EC2Rescue for Windows Server CLI 的範例。

#### 線上模式範例
<a name="ec2rw-collect-examples-online"></a>

收集所有可用的日誌：

```
EC2RescueCmd /accepteula /online /collect:all /output:<outputFilePath>
```

只收集特定的日誌群組：

```
EC2RescueCmd /accepteula /online /collect:ec2config /output:<outputFilePath>
```

收集日誌群組內的個別日誌：

```
EC2RescueCmd /accepteula /online /collect:'ec2config.Log Files,driver-setup.SetupAPI Log Files' /output:<outputFilePath>
```

#### 離線模式範例
<a name="ec2rw-collect-examples-offline"></a>

收集 EBS 磁碟區中所有可用的日誌。磁碟區依 device\$1id 值指定。

```
EC2RescueCmd /accepteula /offline:xvdf /collect:all /output:<outputFilePath>
```

只收集特定的日誌群組：

```
EC2RescueCmd /accepteula /offline:xvdf /collect:ec2config /output:<outputFilePath>
```

## 救援動作
<a name="ec2rw-rescue"></a>

EC2Rescue for Windows Server 可以偵測並解決下列服務設定的問題：


|  服務群組  | 可用動作 |  描述  | 
| --- | --- | --- | 
| all |  |  | 
| system-time | 'RealTimeIsUniversal' | 系統時間[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/ec2rw-cli.html) | 
| firewall |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/ec2rw-cli.html)  |  Windows 防火牆 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/ec2rw-cli.html)  | 
| rdp |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/ec2rw-cli.html)  |  遠端桌面 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/ec2rw-cli.html)  | 
| ec2config |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/ec2rw-cli.html)  |  EC2Config [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/ec2rw-cli.html)  | 
| ec2launch | 'Reset Administrator Password' | 產生新的 Windows 管理員密碼。 | 
| network | 'DHCP Service Startup' |  網路界面 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/ec2rw-cli.html)  | 

以下為可用的選項：
+ **/level:<level>** ‐ 動作應該觸發的檢查層級選用屬性。允許的值為：`information`、`warning`、`error`、`all`。預設會設定為 `error`。
+ **/check-only** ‐ 會產生報告但不修改離線磁碟區的選用屬性。
**注意**  
如果 EC2Rescue for Windows Server 偵測到可能的磁碟簽章衝突，它會在離線處理程序預設完成後更正簽章，即使您使用 `/check-only` 選項也是如此。您必須使用 `/no-fix-signature` 選項來防止更正。
+ **/no-offline** ‐ 在動作完成後防止將磁碟區設為離線的選用屬性。
+ **/no-fix-signature** ‐ 完成動作後不會修正可能磁碟簽章衝突的選用屬性。

### 救援範例
<a name="ec2rw-rescue-examples"></a>

以下是使用EC2Rescue for Windows Server CLI 的範例。磁碟區使用 device\$1id 值指定。

嘗試修正磁碟區中找到的所有問題：

```
EC2RescueCmd /accepteula /offline:xvdf /rescue:all
```

嘗試修正磁碟區服務群組內的所有問題：

```
EC2RescueCmd /accepteula /offline:xvdf /rescue:firewall
```

嘗試修正磁碟區服務群組內的特定項目：

```
EC2RescueCmd /accepteula /offline:xvdf /rescue:rdp.'Service Start'
```

指定磁碟區中嘗試修正的多個問題：

```
EC2RescueCmd /accepteula /offline:xvdf /rescue:'system-time.RealTimeIsUniversal,ec2config.Service Start'
```

## 還原動作
<a name="ec2rw-restore"></a>

EC2Rescue for Windows Server 可以偵測並解決下列服務設定的問題：


|  服務群組  | 可用的動作 |  描述  | 
| --- | --- | --- | 
|  還原上一個已知的良好組態  | lkgc | Last Known Good Configuration (上一個已知的良好組態) - 嘗試將執行個體開機為上一個已知的可開機狀態。 | 
| 從最新的備份還原 Windows 登錄 | regback | Restore registry from backup (從備份還原登錄) - 從 \$1Windows\$1System32\$1config\$1RegBack 還原登錄。 | 

以下為可用的選項：
+ **/no-offline**—在動作完成後防止將磁碟區設為離線的選用屬性。
+ **/no-fix-signature**—完成動作後不會修正可能磁碟簽章衝突的選用屬性。

### 還原範例
<a name="ec2rw-restore-examples"></a>

以下是使用EC2Rescue for Windows Server CLI 的範例。磁碟區使用 device\$1id 值指定。

還原磁碟區中上一個已知的良好組態：

```
EC2RescueCmd /accepteula /offline:xvdf /restore:lkgc
```

在磁碟區上還原上一個 Windows 登錄備份：

```
EC2RescueCmd /accepteula /offline:xvdf /restore:regback
```