

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

# 搭配使用 `DeregisterScalableTarget` 與 CLI
<a name="example_application-auto-scaling_DeregisterScalableTarget_section"></a>

下列程式碼範例示範如何使用 `DeregisterScalableTarget`。

------
#### [ CLI ]

**AWS CLI**  
**取消註冊可擴展的目標**  
此範例取消註冊在預設叢集中執行稱為 Web 應用程式之 Amazon ECS 服務的可擴展目標。  
命令：  

```
aws application-autoscaling deregister-scalable-target --service-namespace {{ecs}} --scalable-dimension {{ecs:service:DesiredCount}} --resource-id {{service/default/web-app}}
```
此範例取消註冊自訂資源的可擴展目標。custom-resource-id.txt 檔案包含可識別資源 ID 的字串，而對於自訂資源而言，該字串是經由 Amazon API Gateway 端點前往自訂資源的路徑。  
命令：  

```
aws application-autoscaling deregister-scalable-target --service-namespace {{custom-resource}} --scalable-dimension {{custom-resource:ResourceType:Property}} --resource-id {{file://~/custom-resource-id.txt}}
```
custom-resource-id.txt 檔案的內容：  

```
https://example.execute-api.us-west-2.amazonaws.com/prod/scalableTargetDimensions/1-23456789
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeregisterScalableTarget](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/application-autoscaling/deregister-scalable-target.html)。

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**範例 1：此 Cmdlet 會取消註冊 Application Auto Scaling 可擴展的目標。取消註冊可擴展的目標會刪除與其相關聯的擴展政策。**  

```
Remove-AASScalableTarget -ResourceId fleet/MyFleet -ScalableDimension appstream:fleet:DesiredCapacity -ServiceNamespace AppStream
```
**輸出：**  

```
Confirm
Are you sure you want to perform this action?
Performing the operation "Remove-AASScalableTarget (DeregisterScalableTarget)" on target "fleet/MyFleet".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): Y
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V4)》**中的 [DeregisterScalableTarget](https://docs.aws.amazon.com/powershell/v4/reference)。

**Tools for PowerShell V5**  
**範例 1：此 Cmdlet 會取消註冊 Application Auto Scaling 可擴展的目標。取消註冊可擴展的目標會刪除與其相關聯的擴展政策。**  

```
Remove-AASScalableTarget -ResourceId fleet/MyFleet -ScalableDimension appstream:fleet:DesiredCapacity -ServiceNamespace AppStream
```
**輸出：**  

```
Confirm
Are you sure you want to perform this action?
Performing the operation "Remove-AASScalableTarget (DeregisterScalableTarget)" on target "fleet/MyFleet".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): Y
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [DeregisterScalableTarget](https://docs.aws.amazon.com/powershell/v5/reference)。

------

如需 AWS SDK 開發人員指南和程式碼範例的完整清單，請參閱 [搭配 AWS SDK 使用此服務](sdk-general-information-section.md)。此主題也包含有關入門的資訊和舊版 SDK 的詳細資訊。