

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

# 配額管理
<a name="fsrm-quota-management"></a>

您可以使用 File Server Resource Manager (FSRM) 配額管理來控制使用者在 FSx for Windows File Server 檔案系統上使用的儲存空間量。配額透過限制可存放在特定資料夾中的資料量，以及在儲存用量接近或超過定義的閾值時產生通知，協助您管理儲存容量。

## 配額管理的運作方式
<a name="fsrm-quota-management-how-it-works"></a>

配額管理提供兩種類型的配額，您可以套用至檔案系統上的資料夾：

硬性配額  
防止使用者在達到配額限制後儲存檔案。當使用者嘗試儲存超過配額限制的檔案時，操作會失敗，且使用者會收到錯誤訊息。

軟配額  
允許使用者在記錄違規時超過配額限制。軟配額適用於監控儲存體用量，而無須強制嚴格限制。

## 配額範本
<a name="fsx-quota-templates"></a>

配額範本提供可重複使用的組態，可定義配額設定，包括大小限制、配額類型 （硬式或軟式） 和閾值通知。建立配額範本之後，您可以將其套用至多個資料夾，而不必每次重新設定相同的設定。當您更新配額範本時，您可以選擇將變更套用至從該範本建立的所有配額。

使用配額範本有幾個優點：
+ **一致性** - 確保類似的資料夾具有相同的配額組態
+ **效率** - 快速將配額設定套用至多個資料夾
+ 可**維護性** - 透過修改範本，跨多個資料夾更新配額設定

## 自動套用配額
<a name="fsx-auto-apply-quotas"></a>

自動套用配額會根據指定的範本自動建立子資料夾的配額。當您在父資料夾上建立自動套用配額時，FSRM 會自動為每個現有子資料夾和使用者未來建立的任何新子資料夾產生配額。此方法適用於您想要在多個使用者目錄或部門資料夾之間套用一致配額限制的情況。

## 閾值通知
<a name="fsx-threshold-notifications"></a>

閾值定義 FSRM 採取特定動作的用量層級。您可以為每個配額設定多個閾值，並將每個閾值設定為配額限制的百分比。當儲存體用量達到閾值百分比時，FSRM 可以執行下列動作：

事件記錄  
將事件記錄到 Amazon CloudWatch 或 Amazon Kinesis Data Firehose 以進行監控和分析。您可以指定事件嚴重性等級 （資訊、警告或錯誤），並提供自訂訊息內文。事件記錄對於監控配額用量以及與現有監控系統整合非常有用。

儲存報告  
產生儲存用量報告，提供使用儲存空間之檔案和資料夾的詳細資訊。儲存報告可協助您識別哪些使用者或應用程式耗用最多的儲存體，並做出有關儲存體管理的明智決策。如需詳細資訊，請參閱[儲存報告](fsrm-storage-reports.md)。

您可以為每個配額設定多個具有不同動作的閾值。例如，您可以使用 75% 用量的資訊事件和 90% 用量的警告事件來設定配額。

## Quota Management 命令
<a name="fsrm-quota-management-commands"></a>

您可以存取三個 FSx 遠端 PowerShell 命令系列來管理配額：

1. **配額命令** - 在特定資料夾上建立、擷取、修改、移除和更新配額。當您需要folder-by-folder管理配額時，請使用這些命令。

1. **配額範本命令** - 建立、擷取和修改定義可重複使用配額組態的配額範本。使用這些命令來建立標準配額政策，您可以將這些政策套用至多個資料夾。

1. **Auto Quota 命令** - 建立、擷取、修改、移除和更新自動套用配額，以自動產生子資料夾的配額。當您需要跨多個子資料夾套用一致的配額限制，而無需手動建立個別配額時，請使用這些命令。

### Quota Management FSx 遠端 PowerShell 命令的清單
<a name="fsx-quota-powershell-commands-list"></a>

**注意**  
此頁面中的所有範例都假設您已使用檔案系統的 Windows Remote PowerShell 端點定義 ` $FSxWindowsRemotePowerShellEndpoint`變數。您可以在檔案系統的詳細資訊頁面上的 Amazon FSx 主控台中找到此端點，或使用 AWS CLI `describe-file-systems`命令。

### 配額命令
<a name="fsx-quota-commands"></a>

#### New-FSxFSRMQuota
<a name="new-fsxfsrmquota"></a>

在資料夾上建立新的配額。配額會限制使用者可以存放在資料夾中的資料量。您可以選擇性地設定配額，以便在使用者超過配額閾值時產生通知。

 **參數：**
+ `Folder (string)` - 必要。套用配額的資料夾路徑。
+ `Size (string)` - 不使用範本時為必要：配額大小限制。
+ `Template (string)` - 選用。要使用的現有配額範本名稱。當您指定範本時，您只能使用描述參數；所有其他設定都會繼承自範本。
+ `Description (string)` - 選用。配額的描述。
+ `SoftLimit (boolean)` - 選用。如果設為 true， 會建立軟配額，允許使用者在記錄違規時超過限制。
+ `Disabled (boolean)` - 選用。如果設為 true， 會以停用狀態建立配額。
+ `ThresholdConfigurations (array)` - 選用。閾值組態陣列，指定在不同用量層級要採取的動作。每個組態都有下列屬性：
  + `ThresholdPercentage (number)`：觸發動作的配額限制百分比。輸入介於 0 到 250 之間的值。
  + `Action (array)`：達到閾值時要採取的一或多個動作。每個動作都有下列屬性：
    + `ActionType`：要執行的動作類型。您可以指定下列值：

      1. `Event`：將事件記錄到檔案系統的事件日誌。當您指定事件時，也必須指定下列屬性：
         + `EventType`：資訊、警告或錯誤
         + `MessageBody`：使用事件記錄的訊息文字。

      1. `Report`：產生儲存用量報告。

 **範例**：

 **1。建立硬式 5GB 配額，而不使用配額範本。**

```
Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock { 
    New-FSxFSRMQuota -Folder "share\test" -Size 5GB 
}
```

 **2. 使用閾值通知建立軟配額** 

```
$thresholds = [System.Collections.ArrayList]@() 
$warning = @{ 
    ThresholdPercentage = 75 
    Action = @( 
        @{ 
            ActionType = "Event" 
            EventType = "Warning" 
            MessageBody = "Quota usage has reached 75%" 
        } 
    ) 
} 

$thresholds.Add($warning) 

Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ArgumentList ($thresholds) -ScriptBlock { 
        param($thresholds)  
        New-FSxFSRMQuota -Folder "share/test" -Size 1GB -Description "Test quota" -SoftLimit -ThresholdConfigurations $Using:thresholds 
}
```

#### Get-FSxFSRMQuota
<a name="get-fsxfsrmquota"></a>

從檔案系統擷取一或多個配額。命令會傳回配額組態的詳細資訊，包括大小限制、閾值和目前用量。

 **參數：**
+ `Folder (string)` - 選用。要從中擷取配額的資料夾路徑。如果您未指定資料夾路徑，命令會傳回檔案系統上的所有配額。

 **範例**：

 **1。取得檔案系統上所有現有的配額。**

```
Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock {
    Get-FSxFSRMQuota
}
```

#### Remove-FSxFSRMQuota
<a name="remove-fsxfsrmquota"></a>

從檔案系統上指定的資料夾移除配額。

 **參數：**
+ `Folder (string)` - 必要。要從中移除配額的資料夾路徑。
+ `PassThru (boolean)` - 選用。如果設定為 true， 會傳回移除的配額物件。

 **範例**：

 **1。移除配額。**

```
Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock { 
    Remove-FSxFSRMQuota -Folder "share\test" -PassThru 
}
```

#### Set-FSxFSRMQuota
<a name="set-fsxfsrmquota"></a>

修改現有配額的組態。

 **參數：**
+ `Folder (string)` - 必要。包含要修改配額的資料夾路徑。
+ `Description (string)` - 選用。配額的新描述。
+ `Size (string)` - 選用。配額的新大小限制。
+ `SoftLimit (boolean)` - 選用。如果設為 true， 會將配額變更為軟性限制，讓使用者在記錄違規時超過限制。
+ `Disabled (boolean)` - 選用。如果設定為 true， 會停用配額。如果設定為 false，請啟用配額。
+ `ThresholdConfigurations (array)` - 選用。新閾值組態的陣列。每個閾值組態都有下列屬性：
  + `ThresholdPercentage (number)`：觸發動作的配額限制百分比。輸入介於 0 到 250 之間的值。
  + `Action (array)`：達到閾值時要採取的一或多個動作。每個動作都有下列屬性：
    + `ActionType`：要執行的動作類型。您可以指定下列值：

      1. `Event`：將事件記錄到檔案系統的事件日誌。當您指定事件時，也必須指定下列屬性：
         + `EventType`：資訊、警告或錯誤
         + `MessageBody`：使用事件記錄的訊息文字。

      1. `Report`：產生儲存用量報告。
+ `PassThru (boolean)` - 選用。如果設定為 true， 會傳回修改後的配額物件。

 **範例**：

 **1。修改配額大小和描述。**

```
Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock { 
    Set-FSxFSRMQuota 	-Folder "share\department" 	-Size 2GB 	-Description "Updated quota for department share" 
}
```

 **2. 停用配額** 

```
Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock { 
    Set-FSxFSRMQuota -Folder "share\department" -Disabled: $true 
}
```

#### Update-FSxFSRMQuota
<a name="update-fsxfsrmquota"></a>

掃描 資料夾以判斷實際使用的空間量，以重新計算配額的目前用量統計資料。

 **參數：**
+ `Folder (string)` - 必要。包含要更新的配額的資料夾路徑。
+ `PassThru (boolean)` - 選用。如果設定為 true， 會傳回更新的配額物件。

 **範例**：

 **1。重新計算指定配額的目前用量統計資料。**

```
Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock {
    Update-FSxFSRMQuota -Folder "share\department" -PassThru
}
```

### 配額範本命令
<a name="fsx-quota-template-commands"></a>

#### New-FSxFSRMQuotaTemplate
<a name="new-fsxfsrmquotatemplate"></a>

建立新的配額範本，以定義配額的可重複使用組態。

 **參數：**
+ `Name (string)` - 必要。配額範本的名稱。
+ `Size (string)` - 必要。配額範本強制執行的大小限制。
+ `Description (string)` - 選用。配額範本的說明。
+ `SoftLimit (boolean)` - 選用。如果設為 true， 會為軟性配額建立範本，以報告用量，但不強制執行限制。
+ `ThresholdConfigurations (array)` - 選用。閾值組態陣列，指定在不同用量層級要採取的動作。每個組態都有下列屬性：
  + `ThresholdPercentage (number)`：觸發動作的配額限制百分比。輸入介於 0 到 250 之間的值。
  + `Action (array)`：達到閾值時要採取的一或多個動作。每個動作都有下列屬性：
    + `ActionType`：要執行的動作類型。您可以指定下列值：

      1. `Event`：將事件記錄到檔案系統的事件日誌。當您指定事件時，也必須指定下列屬性：
         + `EventType`：資訊、警告或錯誤
         + `MessageBody`：使用事件記錄的訊息文字。

      1. `Report`：產生儲存用量報告。

 **範例**：

 **1。建立硬式 1 GB 限制範本。**

```
Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock { 
    New-FSxFSRMQuotaTemplate -Name "1GB Hard Limit" -Size 1GB -Description "Standard 1GB hard limit template" 
}
```

 **2. 建立 5 GB 軟性限制範本，警告閾值為 90% 用量** 

```
$threshold = @{ 
    ThresholdPercentage = 90 
    Action = @( 
        @{ 
            ActionType = "Event" 
            EventType = "Warning" 
            MessageBody = "Quota usage has reached 90% of the limit" 
        } 
    ) 
} 

$thresholds = [System.Collections.ArrayList]@() 
$thresholds.Add($threshold) 

Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ArgumentList $thresholds -ScriptBlock { 
    param($thresholds) 

    New-FSxFSRMQuotaTemplate -Name "5GB Soft Limit" -Size 5GB -Description "5GB soft limit with 90% warning" -SoftLimit -ThresholdConfigurations $Using:thresholds 
}
```

#### Get-FSxFSRMQuotaTemplate
<a name="get-fsxfsrmquotatemplate"></a>

從檔案系統擷取一或多個配額範本。

 **參數：**
+ `Name (string)` - 選用。要擷取的特定配額範本名稱。如果您未指定名稱，命令會傳回所有配額範本。

 **範例**：

 **1。擷取檔案系統上的所有配額範本。**

```
Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock {
    Get-FSxFSRMQuotaTemplate
}
```

#### Set-FSxFSRMQuotaTemplate
<a name="set-fsxfsrmquotatemplate"></a>

修改配額範本的屬性。

 **參數：**
+ `Name (string)` - 必要。要修改的配額範本名稱。
+ `Description (string)` - 選用。範本的新描述。
+ `Size (string)` - 選用。範本的新大小限制。
+ `SoftLimit (boolean)` - 選用。如果設為 true， 會變更範本以建立軟性配額來報告用量，但不強制執行限制。
+ `ThresholdConfigurations (array)` - 選用。閾值組態陣列，指定在不同用量層級要採取的動作。每個組態都有下列屬性：
  + `ThresholdPercentage (number)`：觸發動作的配額限制百分比。輸入介於 0 到 250 之間的值。
  + `Action (array)`：達到閾值時要採取的一或多個動作。每個動作都有下列屬性：
    + `ActionType`：要執行的動作類型。您可以指定下列值：

      1. `Event`：將事件記錄到檔案系統的事件日誌。當您指定事件時，也必須指定下列屬性：
         + `EventType`：資訊、警告或錯誤
         + `MessageBody`：使用事件記錄的訊息文字。

      1. `Report`：產生儲存用量報告。
+ `UpdateDerived (boolean)` - 選用。如果設為 true， 會更新從此範本建立的所有配額。
+ `UpdateDerivedMatching (boolean)` - 選用。如果設為 true，則 只會更新從此範本建立且自建立以來尚未修改的配額。
+ `PassThru (boolean)` - 選用。如果設定為 true， 會傳回修改後的範本物件。

 **範例**：

 **1。修改配額範本的大小和描述。**

```
Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock { 
    Set-FSxFSRMQuotaTemplate -Name "5GB Soft Limit" -Size 10GB -Description "Updated to 10GB soft limit" 
}
```

 **2. 修改配額範本，並更新從範本建立的所有配額。**

```
Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock { 
    Set-FSxFSRMQuotaTemplate -Name "1GB Hard Limit" -Size 2GB -UpdateDerived 
}
```

#### Reset-FSxFSRMQuota
<a name="reset-fsxfsrmquota"></a>

重設配額以符合指定範本的設定。

#### Parameters
<a name="reset-fsxfsrmquota-parameters"></a>
+ `Folder (string)` - 必要。包含要重設配額的資料夾路徑。
+ `Template (string)` - 必要。要套用的配額範本名稱。

#### 範例
<a name="reset-fsxfsrmquota-examples"></a>

 **範例：重設配額以符合配額範本中定義的設定。**

```
Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock { 
    Reset-FSxFSRMQuota -Folder "share\department" -Template "1GB Hard Limit" 
}
```

### 自動配額命令
<a name="auto-quota-commands"></a>

#### New-FSxFSRMAutoQuota
<a name="new-fsxfsrmautoquota"></a>

`New-FSxFSRMAutoQuota` 命令會在指定的資料夾上建立自動套用配額。自動套用配額會根據每個現有子資料夾的指定範本，以及在指定資料夾中建立的任何新子資料夾，自動產生配額。

##### Parameters
<a name="new-fsxfsrmautoquota-parameters"></a>
+ `Folder (string)` - 必要。建立自動套用配額的資料夾路徑。
+ `Template (string)` - 選用。用於自動套用配額的現有配額範本名稱。
+ `Disabled (boolean)` - 選用。如果設定為 true， 會在停用狀態下建立自動套用配額。

##### 範例
<a name="new-fsxfsrmautoquota-examples"></a>

 **1。建立自動套用配額，以自動將指定的範本套用至所有子資料夾。**

```
Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock {
    New-FSxFSRMAutoQuota -Folder "share\department" -Template "250 MB Extended Limit" 
}
```

#### Get-FSxFSRMAutoQuota
<a name="get-fsxfsrmautoquota"></a>

`Get-FSxFSRMAutoQuota` 命令會從檔案系統擷取一或多個自動套用配額。

##### Parameters
<a name="get-fsxfsrmautoquota-parameters"></a>
+ `Folder (string)` - 選用。要從中擷取自動套用配額的資料夾路徑。您也可以`...`在路徑結尾使用 來包含所有子資料夾。

如果您未指定資料夾路徑，命令會在檔案系統上傳回所有自動套用配額。

##### 範例
<a name="get-fsxfsrmautoquota-examples"></a>

 **1。擷取檔案系統上的所有自動套用配額。**

```
Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock {
    Get-FSxFSRMAutoQuota
}
```

#### Remove-FSxFSRMAutoQuota
<a name="remove-fsxfsrmautoquota"></a>

`Remove-FSxFSRMAutoQuota` 命令會從指定的資料夾移除自動套用配額。當您移除自動套用配額時，命令也會從衍生自相關聯配額範本的子資料夾移除所有配額。

##### Parameters
<a name="remove-fsxfsrmautoquota-parameters"></a>
+ `Folder (string)` - 必要。要從中移除自動套用配額的資料夾路徑。
+ `PassThru (boolean)` - 選用。如果設定為 true， 會傳回移除的自動套用配額物件。

##### 範例
<a name="remove-fsxfsrmautoquota-examples"></a>

 **1。從特定資料夾移除自動套用配額。**

```
Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock {
    Remove-FSxFSRMAutoQuota -Folder "share\department" -PassThru
}
```

#### Set-FSxFSRMAutoQuota
<a name="set-fsxfsrmautoquota"></a>

`Set-FSxFSRMAutoQuota` 命令會修改自動套用配額的組態設定。

##### Parameters
<a name="set-fsxfsrmautoquota-parameters"></a>
+ `Folder (string)` - 必要。包含要修改之自動套用配額的資料夾路徑。
+ `Template (string)` - 選用。要套用的配額範本名稱。
+ `Disabled (boolean)` - 選用。如果設為 true， 會停用自動套用配額。如果設定為 false，則啟用自動套用配額。
+ `UpdateDerived (boolean)` - 選用。如果設為 true， 會更新衍生自此自動套用配額的所有現有配額。
+ `UpdateDerivedMatching (boolean)` - 選用。如果設為 true， 只會更新自建立以來尚未修改的衍生配額。
+ `PassThru (boolean)` - 選用。如果設定為 true， 會傳回修改過的自動套用配額物件。

##### 範例
<a name="set-fsxfsrmautoquota-examples"></a>

 **1。變更自動套用配額所使用的配額範本。**

```
Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock {
    Set-FSxFSRMAutoQuota -Folder "share\department" -Template "100 MB Limit" 
}
```

 **2. 停用自動套用配額，並更新衍生自該配額的所有配額。**

```
Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock {
    Set-FSxFSRMAutoQuota -Folder "share\department" -Disabled: $true -UpdateDerived
}
```

#### Update-FSxFSRMAutoQuota
<a name="update-fsxfsrmautoquota"></a>

`Update-FSxFSRMAutoQuota` 命令會重新計算自動套用配額的屬性，以及從中衍生的配額，方法是掃描 資料夾以判斷實際使用的空間量。

##### Parameters
<a name="update-fsxfsrmautoquota-parameters"></a>
+ `Folder (string)` - 必要。包含要更新的自動套用配額的資料夾路徑。
+ `PassThru (boolean)` - 選用。如果設定為 true， 會傳回更新的自動套用配額物件。

##### 範例
<a name="update-fsxfsrmautoquota-examples"></a>

 **1。重新計算用量統計資料，並傳回更新的自動套用配額物件。**

```
Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock {
    Update-FSxFSRMAutoQuota -Folder "share\department" -PassThru
}
```