Using filesystem reporting

A useful feature of the FSRM component is reporting. FSRM defines a number of basic report types that you can request. The reports can either be generated immediately (also known as interactive) or at a scheduled time. The latter causes FSRM to generate reports on a weekly or monthly basis.

Getting ready

Run this recipe on SRV1, after installing the FSRM feature. You did this in the Managing Filestore quotas recipe. That recipe also created two largish files. If you haven't run that recipe, consider creating a few large files on SRV1 before running this recipe.

How to do it...

  1. Create a new interactive Storage Report for large files on C: on SRV1:
    $NRHT = @{
      Name             = 'Large Files on SRV1'
      NameSpace        = 'C:'
      ReportType       = 'LargeFiles'
      LargeFileMinimum = 10MB 
      Interactive      = $True 
      }
    New-FsrmStorageReport @NRHT
  2. Get the current FSRM reports:
    Get-FsrmStorageReport *
  3. After the large file storage report is run, view the results in the filestore:
    $Path = 'C:StorageReportsInteractive'
    Get-ChildItem -Path $Path
  4. View the HTML report:
    $Rep = Get-ChildItem -Path $path*.html
    Invoke-item -Path $Rep
  5. Extract key information from the XML:
    $XF   = Get-ChildItem -Path $Path*.xml  # Find the XML file
    $XML  = [XML] (Get-Content -Path $XF)    # Load file as XML
    $Files = $XML.StorageReport.ReportData.Item # Get large files
    $Files | Where-Object Path -NotMatch '^Windows|^Program|^Users'|
      Format-Table -Property Name, Path,
               @{Name       ='Sizemb'
                 Expression = {(([int]$_.size)/1mb).ToString('N2')}
                },
                DaysSinceLastAccessed -AutoSize 
  6. Create a monthly FSRM task in the task scheduler:
    $Date = Get-Date
    $NTHT = @{
      Time    = $Date
      Monthly = 1
    }
    $Task = New-FsrmScheduledTask @NTHT
    $NRHT = @{
      Name             = 'Monthly Files by files group report'
      Namespace        = 'C:'
      Schedule         = $Task 
      ReportType       = 'FilesbyFileGroup'
      FileGroupINclude = 'text files'
      LargeFileMinimum = 25MB
    }
    New-FsrmStorageReport @NRHT | Out-Null
  7. Get the details of the task:
    Get-ScheduledTask | 
      Where-Object Taskname -Match 'Monthly' |
        Format-Table -AutoSize
  8. Start the scheduled task:
    Get-ScheduledTask -TaskName '*Monthly*' | 
      Start-ScheduledTask
    Get-ScheduledTask -TaskName '*Monthly*'
  9. View the report:
    $Path = 'C:StorageReportsScheduled'
    $Rep = Get-ChildItem -Path $path*.html
    Invoke-item -Path $Rep

How it works…

In step 1, you use the New-FsrmStorageReport to create a report to report any files over 10 MB on C:, which generates the following output:

How it works…

In step 2, you view the existing FSRM reports, which looks like this:

How it works…

After the large file storage report is run, in step 3, you view the results in the filestore, which looks like this:

How it works…

In step 4, you view the HTML report, which looks like this:

How it works…

In step 5, you extract information from the XML version of the interactive large-file FSRM report, which looks like this:

How it works…

In step 6, you set up a scheduled report that produces no output. In step 7, you view the details of the report:

How it works…

In step 8, you start the task you defined in step 7, and view that this report is running, which looks like this:

How it works…

In step 9, you view the report of files by file groups, which looks like this:

How it works…

There's more...

In step 2, you view the current FSRM reports using the Get-FsrmStorageReport cmdlet. This shows all active FSRM reports (scheduled or interactive), although once FSRM completes an interactive report, the report is no longer visible using Get-FsrmStorageReport.

In step 3, you review the output FSRM generated for the interactive storage report. As you can see, there's both an HTML and an XML file. The HTML output looks good (as you see in step 4), but the format is fixed and can't be changed. However, the XML gives you all the information contained in the HTML report. You can use the XML to format the results exactly as you want. The XML file structure is pretty simple and you can pull out the basic information from the XML to create the details you might be interested in, as shown in step 5.

In step 9, you view the second report—a report on files by file group. In this case, the only file group reported is for text files. Were there other files belonging to other file groups, these would be reported.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.40.177