常见使用案例 - FSx 适用于 Windows 文件服务器的亚马逊

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

常见使用案例

本主题提供了文件服务器资源管理器常见任务的 step-by-step示例。这些示例演示了如何使用和实现 FSRM 功能来解决典型的文件管理难题。

注意

本页中的所有示例都假设您已经使用文件系统的 Windows Remote PowerShell 端点定义了该 $FSxWindowsRemotePowerShellEndpoint变量。您可以在文件系统的详细信息页面上的 Amazon FSx 控制台中找到此终端节点,也可以使用 AWS CLI describe-file-systems命令找到此终端节点。

为文件夹设置硬配额

此示例说明如何创建硬配额,防止用户在 “部门” 文件夹中存储超过 10 GB 的空间。

要为文件夹设置配额,请执行以下操作:
  1. 创建限制为 10 GB 的硬配额:

    Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock { New-FSxFSRMQuota -Folder "share\department" -Size 10GB -Description "10 GB hard limit for department folder" }
  2. (可选)修改配额以添加使用率为 85% 的阈值通知:

    $thresholds = [System.Collections.ArrayList]@() $threshold = @{ ThresholdPercentage = 85 Action = @( @{ ActionType = "Event" EventType = "Warning" MessageBody = "Department folder has reached 85% of quota limit" } ) } $null = $thresholds.Add($threshold) Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ArgumentList ($thresholds) -ScriptBlock { param($thresholds) Set-FSxFSRMQuota -Folder "share\department" -ThresholdConfigurations $Using:thresholds }
  3. 验证配额是否已创建:

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

使用文件组限制特定的文件类型

此示例说明如何使用默认 “Audio and Video Files” 文件组阻止用户将音频和视频文件保存到业务文档文件夹。

要使用文件组限制文件类型,请执行以下操作:
  1. 创建一个屏蔽音频和视频文件的活动文件屏幕:

    Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock { New-FSxFSRMFileScreen -Folder "share\business-documents" -IncludeGroup "Audio and Video Files" -Description "Block media files in business documents folder" }
  2. (可选)更新文件屏幕,以便在用户尝试保存被阻止的文件时添加通知:

    $notifications = [System.Collections.ArrayList]@() $eventNotification = @{ ActionType = "Event" EventType = "Warning" MessageBody = "User attempted to save blocked media file" } $null = $notifications.Add($eventNotification) Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ArgumentList $notifications -ScriptBlock { param($notifications) Set-FSxFSRMFileScreen -Folder "share\business-documents" -NotificationConfigurations $Using:notifications }
  3. 验证文件屏幕是否已创建:

    Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock { Get-FSxFSRMFileScreen -Folder "share\business-documents" }

识别和分类 PII 数据

此示例说明如何自动识别包含社会安全号码的文件并将其归类为包含个人身份信息 (PII) 的文件。

要识别和分类 PII 数据,请执行以下操作:
  1. 为 PII 创建分类属性:

    Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock { New-FSxFSRMClassificationPropertyDefinition -Name "ContainsPII" -Type OrderedList -PossibleValueConfigurations @( @{ Name = "Yes" }, @{ Name = "No" }) }
  2. 创建分类规则以检测社会安全号码:

    注意

    以下正则表达式将在文件中搜索带有该模式的文本 XXX-XX-XXXX。对于生产用途,可以考虑使用更复杂的模式或组合多种检测方法。

    Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock { New-FSxFSRMClassificationRule -Name "Detect_SSN" -Property "ContainsPII" -PropertyValue "Yes" -Namespace "share" -ClassificationMechanism "Content Classifier" -ContentRegularExpression "\b\d{3}-\d{2}-\d{4}\b" }
  3. 运行分类:

    Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock { Start-FSxFSRMClassification }
  4. (可选)配置连续分类以自动对新文件进行分类:

    Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock { Set-FSxFSRMClassification -Continuous $true }
  5. 检查状态(1 表示已完成):

    Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock { Get-FSxFSRMClassification }
  6. 分类完成后,您可以通过在 Windows 文件资源管理器中右键单击文件,选择属性,然后选择分类选项卡,来查看分配给文件的分类属性。此选项卡显示文件的所有分类属性及其值。

为文件创建保留策略

此示例说明如何根据文件的文件夹位置按保留期对文件进行分类,然后您可以将其与客户端 PowerShell 脚本一起用于存档或删除文件。

要为文件创建保留策略,请执行以下操作:
  1. 为保留期创建分类属性:

    Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock { New-FSxFSRMClassificationPropertyDefinition -Name "RetentionPeriod" -Type String -Description "File retention period" }
  2. 为不同的保留期创建分类规则:

    • “法律文件” 文件夹下的法律文件保留 7 年:

      Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock { New-FSxFSRMClassificationRule -Name "Legal_7Year" -Property "RetentionPeriod" -PropertyValue "7 years" -Namespace "share/Legal Documents" -ClassificationMechanism "Folder Classifier" }
    • “财:” 文件夹下的财务记录保留 3 年

      Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock { New-FSxFSRMClassificationRule -Name "Finance_3Year" -Property "RetentionPeriod" -PropertyValue "3 years" -Namespace "share/Finance" -ClassificationMechanism "Folder Classifier" }

    您还可以按文件内容进行分类并搜索诸如 “保留期七年” 之类的字符串。为此,请使用ClassificationMechanism "Content Classifier"ContentString "Retention seven years"

  3. 运行分类以应用保留属性:

    Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock { Start-FSxFSRMClassification }
  4. (可选)配置连续分类以自动对新文件进行分类:

    Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock { Set-FSxFSRMClassification -Continuous $true }
  5. 检查状态(1 表示已完成):

    Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock { Get-FSxFSRMClassification }
  6. 分类完成后,您可以通过在 Windows 文件资源管理器中右键单击文件,选择属性,然后选择分类选项卡,来查看分配给文件的分类属性。此选项卡显示文件的所有分类属性及其值。

  7. 根据保留期对文件进行分类后,您可以使用客户端 PowerShell 脚本根据文件的RetentionPeriod属性和期限对其进行存档或删除。例如,您可以扫描文件系统并将文件的保存期限与其保留期分类进行比较。有关更多信息,请参阅 文件管理任务

设置常用存储报告

本节介绍如何创建两个常用的存储报告:大文件报告和所有者文件报告。

大文件报告

此示例创建一个月度报告,用于识别大于 200 MB 的文件。

要创建大文件报告,请执行以下操作:
  1. 创建计划的大文件报告:

    $schedule = @{ Time = "2:00 AM" Monthly = @(1) # Run on the 1st of each month } Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ArgumentList $schedule -ScriptBlock { param($schedule) New-FSxFSRMStorageReport -Name "Monthly Large Files Report" -Namespace "share" -ReportType "LargeFiles" -LargeFileMinimum 200MB -ReportFormat "HTML","CSV" -ScheduleConfigurations $schedule }
  2. (可选)立即运行报告进行测试:

    Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock { Start-FSxFSRMStorageReport -Name "Monthly Large Files Report" }

按所有者列出的文件报告

此示例创建每周报告,显示用户的存储消耗情况。

要按所有者报告创建文件,请执行以下操作:
  1. 按所有者报告创建预定文件:

    $schedule = @{ Time = "3:00 AM" Weekly = @('Sunday') } Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ArgumentList $schedule -ScriptBlock { param($schedule) New-FSxFSRMStorageReport -Name "Weekly Files by Owner Report" -Namespace "share" -ReportType "FilesByOwner" -ReportFormat "HTML","CSV" -ScheduleConfigurations $schedule }
  2. (可选)立即运行报告进行测试:

    Invoke-Command -ComputerName $FSxWindowsRemotePowerShellEndpoint -ConfigurationName FSxRemoteAdmin -ScriptBlock { Start-FSxFSRMStorageReport -Name "Weekly Files by Owner Report" }

通过映射管理 D$ 共享来访问生成的报告。有关更多信息,请访问访问存储报告