

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 [AWS SDK 範例](https://github.com/awsdocs/aws-doc-sdk-examples)。

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

# AWS 價格表 使用 Tools for PowerShell V5 的範例
<a name="powershell_5_pricing_code_examples"></a>

下列程式碼範例示範如何使用 AWS Tools for PowerShell V5 搭配 來執行動作和實作常見案例 AWS 價格表。

*Actions* 是大型程式的程式碼摘錄，必須在內容中執行。雖然動作會告訴您如何呼叫個別服務函數，但您可以在其相關情境中查看內容中的動作。

每個範例均包含完整原始碼的連結，您可在連結中找到如何設定和執行內容中程式碼的相關指示。

**Topics**
+ [動作](#actions)

## 動作
<a name="actions"></a>

### `Get-PLSAttributeValue`
<a name="pricing_GetAttributeValues_powershell_5_topic"></a>

以下程式碼範例顯示如何使用 `Get-PLSAttributeValue`。

**Tools for PowerShell V5**  
**範例 1：傳回 us-east-1 區域中 Amazon EC2 之屬性 'volumeType' 的值。**  

```
Get-PLSAttributeValue -ServiceCode AmazonEC2 -AttributeName "volumeType" -region us-east-1
```
**輸出：**  

```
Value
-----
Cold HDD
General Purpose
Magnetic
Provisioned IOPS
Throughput Optimized HDD
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [GetAttributeValues](https://docs.aws.amazon.com/powershell/v5/reference)。

### `Get-PLSProduct`
<a name="pricing_GetProducts_powershell_5_topic"></a>

以下程式碼範例顯示如何使用 `Get-PLSProduct`。

**Tools for PowerShell V5**  
**範例 1：傳回 Amazon EC2 的所有產品的詳細資訊。**  

```
Get-PLSProduct -ServiceCode AmazonEC2 -Region us-east-1
```
**輸出：**  

```
{"product":{"productFamily":"Compute Instance","attributes":{"enhancedNetworkingSupported":"Yes","memory":"30.5 GiB","dedicatedEbsThroughput":"800 Mbps","vcpu":"4","locationType":"AWS Region","storage":"EBS only","instanceFamily":"Memory optimized","operatingSystem":"SUSE","physicalProcessor":"Intel Xeon E5-2686 v4 (Broadwell)","clockSpeed":"2.3 GHz","ecu":"Variable","networkPerformance":"Up to 10 Gigabit","servicename":"Amazon Elastic Compute Cloud","instanceType":"r4.xlarge","tenancy":"Shared","usagetype":"USW2-BoxUsage:r4.xlarge","normalizationSizeFactor":"8","processorFeatures":"Intel AVX, Intel AVX2, Intel Turbo","servicecode":"AmazonEC2","licenseModel":"No License required","currentGeneration":"Yes","preInstalledSw":"NA","location":"US West (Oregon)","processorArchitecture":"64-bit","operation":"RunInstances:000g"},...
```
**範例 2：傳回 us-east-1 區域中的 Amazon EC2 資料，這些資料依照 SSD 支援的「一般用途」磁碟區類型進行篩選。**  

```
Get-PLSProduct -ServiceCode AmazonEC2 -Filter @{Type="TERM_MATCH";Field="volumeType";Value="General Purpose"},@{Type="TERM_MATCH";Field="storageMedia";Value="SSD-backed"} -Region us-east-1
```
**輸出：**  

```
{"product":{"productFamily":"Storage","attributes":{"storageMedia":"SSD-backed","maxThroughputvolume":"160 MB/sec","volumeType":"General Purpose","maxIopsvolume":"10000",...
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [GetProducts](https://docs.aws.amazon.com/powershell/v5/reference)。

### `Get-PLSService`
<a name="pricing_DescribeServices_powershell_5_topic"></a>

以下程式碼範例顯示如何使用 `Get-PLSService`。

**Tools for PowerShell V5**  
**範例 1：傳回 us-east-1 區域中所有可用服務代碼的中繼資料。**  

```
Get-PLSService -Region us-east-1
```
**輸出：**  

```
AttributeNames                                                  ServiceCode
--------------                                                  -----------
{productFamily, servicecode, groupDescription, termType...}     AWSBudgets
{productFamily, servicecode, termType, usagetype...}            AWSCloudTrail
{productFamily, servicecode, termType, usagetype...}            AWSCodeCommit
{productFamily, servicecode, termType, usagetype...}            AWSCodeDeploy
{productFamily, servicecode, termType, usagetype...}            AWSCodePipeline
{productFamily, servicecode, termType, usagetype...}            AWSConfig
...
```
**範例 2：傳回 us-east-1 區域中 Amazon EC2 服務的中繼資料。**  

```
Get-PLSService -ServiceCode AmazonEC2 -Region us-east-1
```
**輸出：**  

```
AttributeNames                                                         ServiceCode
--------------                                                         -----------
{volumeType, maxIopsvolume, instanceCapacity10xlarge, locationType...} AmazonEC2
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [DescribeServices](https://docs.aws.amazon.com/powershell/v5/reference)。