

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

# 驗證您的 Active Directory 組態
<a name="validate-ad-config"></a>

 建立已加入 Active Directory 的 FSx for Windows File Server 檔案系統之前，建議您使用 Amazon FSx Active Directory 驗證工具來驗證 Active Directory 組態。請注意，需要傳出網際網路連線才能成功驗證 Active Directory 組態。<a name="test-ad-network-config"></a>

**驗證您的 Active Directory 組態**

1. 在相同子網路中啟動 Amazon EC2 Windows 執行個體，並使用您用於 FSx for Windows File Server 檔案系統的相同 Amazon VPC 安全群組。確保您的 EC2 執行個體具有必要的 `AmazonEC2ReadOnlyAccess` IAM 許可。您可以使用 IAM 政策模擬器來驗證 EC2 執行個體角色許可。如需詳細資訊，請參閱《[IAM 使用者指南》中的使用 IAM 政策模擬器測試 IAM 政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_testing-policies.html)。 **

1. 將 EC2 Windows 執行個體加入 Active Directory。如需詳細資訊，請參閱《 *AWS Directory Service 管理指南*》中的[手動加入 Windows 執行個體](https://docs.aws.amazon.com/directoryservice/latest/admin-guide/join_windows_instance.html)。

1. 連線至 EC2 執行個體。如需詳細資訊，請參閱《*Amazon EC2 使用者指南》中的*[連線至 Windows 執行個體](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/connecting_to_windows_instance.html)。

1. 在 EC2 執行個體上開啟 Windows PowerShell 視窗 （使用 **Run as Administrator**)。

   若要測試是否已安裝 Windows PowerShell 所需的 Active Directory 模組，請使用下列測試命令。

   

   ```
   PS C:\> Import-Module ActiveDirectory
   ```

   

   如果上述 傳回錯誤，請使用下列命令進行安裝。

   

   ```
   PS C:\> Install-WindowsFeature RSAT-AD-PowerShell
   ```

1. 使用下列命令下載網路驗證工具。

   

   ```
   PS C:\> Invoke-WebRequest "https://docs.aws.amazon.com/fsx/latest/WindowsGuide/samples/AmazonFSxADValidation.zip" -OutFile "AmazonFSxADValidation.zip"
   ```

1. 使用下列命令展開 zip 檔案。

   ```
   PS C:\> Expand-Archive -Path "AmazonFSxADValidation.zip"
   ```

1. 將`AmazonFSxADValidation`模組新增至目前的工作階段。

   ```
   PS C:\> Import-Module .\AmazonFSxADValidation
   ```

1. 將 替換為下列命令來設定必要的參數：
   + Active Directory 網域名稱 (*DOMAINNAME.COM*：//)
   + 使用下列其中一個選項準備服務帳戶密碼的`$Credential`物件。
     + 若要以互動方式產生登入資料物件，請使用下列命令。

       ```
       $Credential = Get-Credential
       ```
     + 若要使用 AWS Secrets Manager 資源產生登入資料物件，請使用下列命令。

       ```
       $Secret = ConvertFrom-Json -InputObject (Get-SECSecretValue -SecretId $AdminSecret).SecretString
       $Credential = (New-Object PSCredential($Secret.UserName,(ConvertTo-SecureString $Secret.Password -AsPlainText -Force)))
       ```
   + DNS 伺服器 IP 地址 (*IP\$1ADDRESS\$11*、*IP\$1ADDRESS\$12*)
   + 您計劃建立 Amazon FSx 檔案系統的子網路 (*SUBNET\$11*、*SUBNET\$12*) 子網路 ID （例如 `subnet-04431191671ac0d19`)。

   ```
   PS C:\> 
   $FSxADValidationArgs = @{
       # DNS root of ActiveDirectory domain
       DomainDNSRoot = 'DOMAINNAME.COM'
   
       # IP v4 addresses of DNS servers
       DnsIpAddresses = @('IP_ADDRESS_1', 'IP_ADDRESS_2')
   
       # Subnet IDs for Amazon FSx file server(s)
       SubnetIds = @('SUBNET_1', 'SUBNET_2')
   
       Credential = $Credential
   }
   ```

1. （選用） 在執行驗證工具之前，遵循隨附`README.md`檔案中的指示，設定組織單位、委派管理員群組、DomainControllersMaxCount 並啟用服務帳戶許可驗證。
**注意**  
如果作業系統不是英文，則`Domain Admins`群組會有不同的名稱。例如， 群組在法文作業系統版本`Administrateurs du domaine`中命名。如果您未指定值，則會使用預設`Domain Admins`群組名稱，且檔案系統建立失敗。

1. 使用此命令執行驗證工具。

   ```
   PS C:\> $Result = Test-FSxADConfiguration @FSxADValidationArgs
   ```

1. 以下是成功測試結果的範例。

   ```
   Test 1 - Validate EC2 Subnets ...
   ...
   Test 17 - Validate 'Delete Computer Objects' permission ...
   
   Test computer object amznfsxtestd53f deleted!
   ...
   SUCCESS - All tests passed! Please proceed to creating an Amazon FSx file system. For your convenience, SelfManagedActiveDirectoryConfiguration of result can be used directly in CreateFileSystemWindowsConfiguration for New-FSXFileSystem
   PS C:\AmazonFSxADValidation> $Result.Failures.Count
   0
   PS C:\AmazonFSxADValidation> $Result.Warnings.Count
   0
   ```

   以下是發生錯誤的測試結果範例。

   ```
   Test 1 - Validate EC2 Subnets ...
   ...
   Test 7 - Validate that provided EC2 Subnets belong to a single AD Site ...
   
   Name          DistinguishedName                                                         Site
   ----          -----------------                                                         ----
   10.0.0.0/19   CN=10.0.0.0/19,CN=Subnets,CN=Sites,CN=Configuration,DC=test-ad,DC=local   CN=SiteB,CN=Sites,CN=Configu...
   10.0.128.0/19 CN=10.0.128.0/19,CN=Subnets,CN=Sites,CN=Configuration,DC=test-ad,DC=local CN=Default-First-Site-Name,C...
   10.0.64.0/19  CN=10.0.64.0/19,CN=Subnets,CN=Sites,CN=Configuration,DC=test-ad,DC=local  CN=SiteB,CN=Sites,CN=Configu...
   
   
   
   Best match for EC2 subnet subnet-092f4caca69e360e7 is AD site CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=te
   st-ad,DC=local
   Best match for EC2 subnet subnet-04431191671ac0d19 is AD site CN=SiteB,CN=Sites,CN=Configuration,DC=test-ad,DC=local
   WARNING: EC2 subnets subnet-092f4caca69e360e7 subnet-04431191671ac0d19 matched to different AD sites! Make sure they
   are in a single AD site.
   ...
   9 of 16 tests skipped.
   FAILURE - Tests failed. Please see error details below:
   
   Name                           Value
   ----                           -----
   SubnetsInSeparateAdSites       {subnet-04431191671ac0d19, subnet-092f4caca69e360e7}
   
   
   
   Please address all errors and warnings above prior to re-running validation to confirm fix.
   PS C:\AmazonFSxADValidation> $Result.Failures.Count
   1
   PS C:\AmazonFSxADValidation> $Result.Failures
   
   Name                           Value
   ----                           -----
   SubnetsInSeparateAdSites       {subnet-04431191671ac0d19, subnet-092f4caca69e360e7}
   
   
   PS C:\AmazonFSxADValidation> $Result.Warnings.Count
   0
   ```

   如果您在執行驗證工具時收到警告或錯誤，請參閱驗證工具套件 (`TROUBLESHOOTING.md`) 和 中包含的故障診斷指南[Amazon FSx 故障診斷](troubleshooting.md)。