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.
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.
C:
on SRV1
:$NRHT = @{ Name = 'Large Files on SRV1' NameSpace = 'C:' ReportType = 'LargeFiles' LargeFileMinimum = 10MB Interactive = $True } New-FsrmStorageReport @NRHT
Get-FsrmStorageReport *
$Path = 'C:StorageReportsInteractive' Get-ChildItem -Path $Path
$Rep = Get-ChildItem -Path $path*.html Invoke-item -Path $Rep
$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
$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
Get-ScheduledTask | Where-Object Taskname -Match 'Monthly' | Format-Table -AutoSize
Get-ScheduledTask -TaskName '*Monthly*' | Start-ScheduledTask Get-ScheduledTask -TaskName '*Monthly*'
$Path = 'C:StorageReportsScheduled' $Rep = Get-ChildItem -Path $path*.html Invoke-item -Path $Rep
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:
In step 2, you view the existing FSRM reports, which looks like this:
After the large file storage report is run, in step 3, you view the results in the filestore, which looks like this:
In step 4, you view the HTML report, which looks like this:
In step 5, you extract information from the XML version of the interactive large-file FSRM report, which looks like this:
In step 6, you set up a scheduled report that produces no output. In step 7, you view the details of the report:
In step 8, you start the task you defined in step 7, and view that this report is running, which looks like this:
In step 9, you view the report of files by file groups, which looks like this:
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.
18.116.40.177