Hey Checkyourlogs Fans,

I know we love Windows Admin Center for pretty much all things Storage Spaces Direct. However, at this time there are a few things that are missing for our wonderful HTML5 UI. The most important thing for Storage Spaces Direct admins is visibility into the ReFS, Deduplication, and Data Integrity logs.

There has been much discussion around the Storage Spaces Direct Community surrounding volumes that go offline due to the DRT (Dirty Region Tracking) tables filling up. This
normally happens when there is a catastrophic event to the cluster such as a hard power failure. Now, it doesn’t happen all the time and from what I have seen in the field only about 5% of cases during a hard failure will this be the case. Now, in the event, you are one of the unlucky 5% you will have event ID’s showing up in the Data Integrity\Crash Recovery event logs.

Because there wasn’t great tracking of this issue, I decided to make a little report and use it as a daily operators report.

Here are some examples of what I want to look for:

  • Storage Spaces Driver Event Log
    • I can see that the last event happened over 6 months ago and it was because a drive went offline. I was pulling the disk at this time, but it could indicate a failure that has or is about to happen. So each morning I read this, and if an event pops up, I can see there is something to action.



  • For Windows Server 2019 I always use Deduplication, and I can see the statistics here, and I can also check the Deduplication Events to make sure everything looks good.



  • Next, you can gather a lot of additional information from the ReFS log regarding stats on the CSV’s for Storage Spaces Direct.


  • Now for the secret sauce – Data Integrity Scans are scheduled by default to run monthly for ReFS enabled Storage Spaces Direct volumes. It does this as kind of a background scrubbing to make sure everything is ok. We do not want to see errors in here.


  • Lastly the log that you DO NOT want to see activity in is the Data Integrity\Crash Debug. If you see activity in here something bad has happened an,d you need to investigate. As you can see in the example below on Sept 7, 2018, a crash recovery scan was initiated. This does not normally start on a schedule and will only kick in if something bad has happened. As mentioned this could be a Network Failure, Power Failure or other catastrophic event.


Now there are some other goodies in the script like:

  • Storage Pool Info
  • Storage Enclosure Info
  • Physical Disk Info
  • Virtual Disk Info


Now you have read this far you are probably wondering where you can find the scripts required for this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
<#
    .SYNOPSIS
    Creates a HTML Report describing Storage Spaces Status, Deduplication, ReFS, Data Integrity, and VM Checkpoints/Replicas
    
    Original Version by :Michael Rüefli (www.miru.ch) - https://gallery.technet.microsoft.com/scriptcenter/Storage-Spaces-Status-2e8e7fbb
    Updated Version by Dave Kawula MVP (www.checkyourlogs.net) @DaveKawula
    Moved up to Github to allow for community edits.
     
    THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE
    RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.
     
    Version 1.2.0 (stable), January 22th, 2015
    Version 2.0.0 (stable), November 16, 2018
     
    .DESCRIPTION
     
    This script creates a HTML report showing the following information about a Windows
    Storage Spaces environment.
     
    * Report Generation Time, Reported Node
    * Storage Pools
    * Storage Enclosures
    * Virtual Disks
    * Physical Disks with Enclosure Mapping
    * MPIO Path Information per physical Disk
    * Storage Spaces Driver Events
    * Storage Tiering Statistics
    * Tested with Storage Spaces and Storage Spaces Direct
    * Runs locally on each node
    * Gathers Diagnostic information for Storage Spaces (ReFS, Data Integrity Scans)
    * Reports on Deduplication
    * Updated and runs on 2016 and 2019
     
     
    .PARAMETER StorageNode
    The hostname of the storage node to query
 
    .PARAMETER IncludeMPIO
    This switch enables MPIO Information gathering
     
    .PARAMETER IncludeEvents
    This switch enables Eventlog Information gathering
 
    .PARAMETER IncludeTieringStats
    This switch enables Storage Tiering statistics gathering
 
    .PARAMETER OutputFile
    This parameter can be used to select an alternate output file location than %TEMP%\StorageReport.html
 
    .PARAMETER IncludeEvents
    This switch opens the report file with the default handler right after creation
 
    .PARAMETER MailFrom
    Email address to send to. Passed directly to Send-MailMessage as -From
     
    .PARAMETER MailTo
    Email address to send to. Passed directly to Send-MailMessage as -To
     
    .PARAMETER MailServer
    SMTP Mail server to attempt to send through. Passed directly to Send-MailMessage as -SmtpServer
     
    .PARAMETER IncludeDedupStats
    Gathers Information on Deduplication on the Storage Pools will work on ReFS and NTFS volumes with Deduplication Enabled
 
    .PARAMETER IncludeRefSDebugEvents
    Gathers infromation from the ReFS Event Logs
 
    .PARAMETER IncludeVMInfo
    Gathers General Information about the Hyper-V VM's and is used for Project Titan for Replicas / CheckPoints
      
    Note --> I have Hard coded the SMTP Settigns for now.
    .EXAMPLE
    Generate the HTML report and send it via Email
    .\CreateStorageReport.ps1 -StorageNode SOFSN01 -IncludeMPIO -IncludeEvents -OutputFile C:\Reports\StorageReport_demo.html -MailFrom storage@domain.com -Mailto support@domain.com -MailServer smtp.domain.com
 
    .NOTES
    Changes / Bugfixes
    V 1.1.0
    - Fixed Storage Enclosure Sensor Health errors
    - Added Physical Disk Reliability Counters
    - Fixed Pool gathering where physical disks where displayed multiple times
    - changed -Mailto Parameter to be an array of Strings to support multiple recipients
 
    V 1.2.0
    - Added Storage Tiering Statistics (-IncludeTieringStats)
 
    V 2.0
    - Added Reporting for ReFS
    - Added Reporting for Deduplication
    - Added Reporting for Data Integrity Scans
    - Added Reporting for Hyper-V Checkpoint and general VM Info
    #>
 
Param(
    [Parameter(Mandatory=$True)]
    [STRING]$StorageNode,
     
    [Parameter(Mandatory=$false)]
    [SWITCH]$IncludeMPIO,
 
    [Parameter(Mandatory=$false)]
    [SWITCH]$IncludeEvents,
 
    [Parameter(Mandatory=$false)]
    [SWITCH]$IncludeTieringStats,
 
    [Parameter(Mandatory=$false)]
    [STRING]$OutPutFile="$ENV:TEMP\StorageReport_$StorageNode.html",
 
    [Parameter(Mandatory=$false)]
    [SWITCH]$OpenFileAfterCreation,
     
    [Parameter(Mandatory=$false)]
    [STRING]$MailFrom,
 
    [Parameter(Mandatory=$false)]
    [STRING[]]$MailTo,
 
    [Parameter(Mandatory=$false)]
    [STRING]$MailServer,
 
    [Parameter(Mandatory=$false)]
    [SWITCH]$IncludeDedupStats,
 
    [Parameter(Mandatory=$false)]
    [SWITCH]$IncludeReFSDebugEvents,
 
    [Parameter(Mandatory=$false)]
    [SWITCH]$IncludeVMInfo
)
 
$VerbosePreference="continue"
 
#We can add this back in later --> For now we are running this all locally
#Create Persistent Remote Session
#Write-Verbose "Creating new WinRM Ression with Computer: $StorageNode"
#$PSSession = New-PSSession -ComputerName $StorageNode
 
#region data gathering
#Get Storage Enclosure Info
Write-Verbose "Gathering Enclosure Information"
$Enclosures = Invoke-Command -ScriptBlock {
    $Enclosures = Get-StorageEnclosure | select *
    $EnclosureInfo = @()
    Foreach ($e in $Enclosures)
    {
 
        $eFANState = $e.FANOperationalStatus -join "."
        $ePWRSupplyState = $e.PowerSupplyOperationalStatus -join "."
        $eIOContrState = $e.IOControllerOperationalStatus -join "."
        $eTempSensorState = $e.TemperatureSensorOperationalStatus -join "."
 
        $encinfo = New-Object -TypeName PSObject -Property @{
            FriendlyName=$e.FriendlyName
            UniqueID=$e.UniqueId
            SerialNumber=$e.SerialNumber
            Firmware=$e.FirmwareVersion
            Slots=$e.NumberOfSlots
            HealthState=$e.HealthStatus
            IOControllerState=$eIOContrState
            FANState=$eFANState
            PowerSupplyState=$ePWRSupplyState
            TemperatureSensorState=$eTempSensorState
        }
        $EnclosureInfo += $encinfo
    }
    return $EnclosureInfo
}
 
#Get Storage Pool Info
Write-Verbose "Gathering Storage Pool Information"
$StoragePoolInfo = Invoke-Command -ScriptBlock  {
    $StoragePoolInfo = @()
    $StoragePools = Get-StoragePool | Where-Object {$_.FriendlyName -ne 'Primordial'}
    Foreach ($sp in $StoragePools)
    {
        $PoolObject = New-Object -TypeName PSObject -Property @{
            FriendlyName=$sp.FriendlyName
            SizeGB=($sp.Size / 1GB)
            AllocatedGB=($sp.AllocatedSize / 1GB)
            AllocatedPercent=[System.Math]::Round((100/$sp.Size)*($sp.AllocatedSize), 2)
            IsClustered=$sp.IsClustered
            EnclosureAwareDefault=$sp.EnclosureAwareDefault
            OperationalStatus=$sp.OperationalStatus
            HealthStatus=$sp.HealthStatus
        }
        $StoragePoolInfo += $PoolObject
    }
    Return $StoragePoolInfo
}
 
#Get virtual Disks
Write-Verbose "Gathering Virtual Disk (Spaces) Information"
$VirtualDiskInfo = Invoke-Command -ScriptBlock  {
    $StoragePools = Get-StoragePool
    $VirtualDiskInfo = @()
 
    Foreach ($sp in $StoragePools)
    {
        $VirtualDisks = Get-VirtualDisk -StoragePool $sp
        Foreach ($vd in $VirtualDisks)
        {
            $StorageTiers = $vd  | Get-StorageTier
            If ($StorageTiers)
            {
                Write-Verbose "Gathering Storage Tier Information"
                $IsTiered=$true
            }
            Else
            {
                $IsTiered=$false
            }
             
            $VirtualDiskobj = New-Object -TypeName PSObject -Property @{
            FriendlyName=$vd.FriendlyName
            StoragePool=$sp.FriendlyName
            ResiliencySettingName=$vd.ResiliencySettingName
            NumberOfDataCopies=$vd.NumberOfDataCopies
            NumberofColumns=$vd.NumberofColumns
            Interleave=$vd.Interleave
            IsEnclosureAware=$vd.IsEnclosureAware
            SizeGB=($vd.Size / 1GB)
            WriteCacheSizeGB=($vd.WriteCacheSize / 1GB)
            IsTiered=$IsTiered
            SSDTierSizeGB=(($StorageTiers | Where-Object {$_.MediaType -eq 'SSD'}).Size / 1GB)
            HDDTierSizeGB=(($StorageTiers | Where-Object {$_.MediaType -eq 'HDD'}).Size / 1GB)
            OperationalStatus=$vd.OperationalStatus
            HealthStatus=$vd.HealthStatus
            }
            $VirtualDiskInfo += $VirtualDiskobj
        }     
 
    
    Return $VirtualDiskInfo
}
 
 
#Get Physical Disks
Write-Verbose "Gathering Physical Disk Information"
$PhysicalDiskInfo = Invoke-Command -ScriptBlock  {
    #$Enclosures = $USING:Enclosures
    $PhysicalDiskInfo = @()
 
    $pdisks = Get-PhysicalDisk | where {($_.canpool) -or ($_.CannotPoolReason -match 'In a Pool')}
    Foreach ($pd in $pdisks)
    {
        $opsdata = Get-StorageReliabilityCounter -PhysicalDisk $pd
        $findstrg = $pd.PhysicalLocation -match '[0-9a-z]{16}'
        $EnslosureID = $matches[0]
        $dskobj = New-Object -TypeName PSObject -Property @{
            Name=$pd.FriendlyName
            Slot=$pd.SlotNumber
            EnclosureID=($EnslosureID)
            EnclosureSerial=($Enclosures | where-object {$_.UniqueId -eq $EnslosureID}).SerialNumber
            HealthState=$pd.HealthStatus
            Manufacturer=$pd.Manufacturer
            Model=$pd.Model
            FirmwareVersion=$pd.FirmwareVersion
            OperationalState=$pd.OperationalStatus
            MediaType=$pd.MediaType
            SizeGB=($pd.Size /1GB)
            Usage=$pd.Usage
            ID=$pd.UniqueId
            SerialNumber=$pd.SerialNumber
            PowerOnHours=$opsdata.PowerOnHours
            Temperature=$opsdata.Temperature
            TemperatureMax=$opsdata.TemperatureMax
            StartStopCycleCount=$opsdata.StartStopCycleCount
            MaxReadLatency_ms=$opsdata.ReadLatencyMax
            MaxWriteLatency_ms=$opsdata.WriteLatencyMax
            ReadErrors=$opsdata.ReadErrorsTotal
            WriteErrors=$opsdata.WriteErrorsTotal
        }
        $PhysicalDiskInfo += $dskobj
        }
    Return $PhysicalDiskInfo
}
 
 
If ($IncludeMPIO)
{
    #Get MPIO Info
    Write-Verbose "Gathering MPIO Path Information per Disk"
    $MPIOPathInfo = Invoke-Command -ScriptBlock {
        $StoragePools = Get-StoragePool | Where-Object {$_.FriendlyName -ne 'Primordial'}
        $MPIOInfo = $StoragePools | Get-PhysicalDisk | Foreach-Object {mpclaim -s -d $_.DeviceID}
        Return $MPIOInfo
    } | Select-String "paths"
}
 
If ($IncludeDedupStats){
    Write-Verbose "Gathering Deduplication Statistics"
 
    $DedupStatus = Get-DedupStatus | Select-Object *
    $DedupVolumeStats = Get-dedupvolume D: | Select *
    $Dedupevents = Get-WinEvent -MaxEvents 10 -LogName Microsoft-Windows-Deduplication/Diagnostic | Select-Object *
    $DedupDiagevents = Get-WinEvent -MaxEvents 10 -LogName Microsoft-Windows-Deduplication/Scrubbing | Select-Object *
}
 
If ($IncludeReFSDebugEvents){
    Write-Verbose "Gathering ReFS Operational Events"
 
     $ReFSEvents = Get-WinEvent -MaxEvents 10 -LogName Microsoft-Windows-ReFS/Operational | Select-Object *
     $DataIntegrityAdmin = Get-WinEvent -MaxEvents 10 -LogName Microsoft-Windows-DataIntegrityScan/Admin | Select-Object *
     $DataIntegrityCrash = Get-WinEvent -MaxEvents 10 -LogName Microsoft-Windows-DataIntegrityScan/CrashRecovery | Select-Object *
}
 
If ($IncludeVMInfo){
    Write-Verbose "Gathering Hyper-V VM Information"
     $VMInfo = @()
     $VMInfo += Get-VM -ComputerName Localhost
#     $VMInfo += Get-VM -ComputerName EPFCS2D2
       
     $VMReplicaInfo = @()
     $VMReplicaInfo =  Get-VM -ComputerName Localhost | Get-VMSnapshot
     #$VMReplicaInfo =  Get-VM -ComputerName EPFCS2D2 | Get-VMSnapshot
}
 
 
If ($IncludeEvents)
{
    Write-Verbose "Gathering Storage Spaces Driver Events"
    #Get Storage Spaces Driver Events
    $StorageSpaceDriverEvts = Invoke-Command -ScriptBlock {
        Get-WinEvent -MaxEvents 20 -LogName  "Microsoft-Windows-StorageSpaces-Driver/Operational"
    }
}
 
If ($IncludeTieringStats)
{
    #Get Storage Tiering Statistics
    Write-Verbose "Gathering Storage Tiering Statistics"
    $TieringStats = Invoke-Command -ScriptBlock {
 
        $TierStats=@()
        $StorageOptInfo = get-winevent -LogName "Microsoft-Windows-Storage-Tiering/Admin" | ? {$_.ID -eq 22}
        Foreach ($entry in $StorageOptInfo)
        {
            $entrydate=$entry.TimeCreated
            $info = $entry.Message
            $info -match 'Percent of total I/Os serviced from the SSD tier: [0-9]{1,3}%' | out-null ; $FastTierHitRate = $matches[0]       
            $info -match 'Current size of the faster .* tier: [0-9]{1,3},[0-9]{1,2}.*?GB' | out-null ; $CurrentFastTierSize = $matches[0]       
            $info -match '100%.*?[0-9]{1,3},[0-9]{1,2}.*?[G|M|K|T]B' | out-null; $FastTierSizeReq100 = ($matches[0]).trim()
            $info -match '95%.*?[0-9]{1,3},[0-9]{1,2}.*?GB|MB|KB' | out-null; $FastTierSizeReq95 = $matches[0]
            $info -match '90%.*?[0-9]{1,3},[0-9]{1,2}.*?GB|MB|KB' | out-null; $FastTierSizeReq90 = $matches[0]
            $info -match '85%.*?[0-9]{1,3},[0-9]{1,2}.*?GB|MB|KB' | out-null; $FastTierSizeReq85 = $matches[0]
            $info -match '80%.*?[0-9]{1,3},[0-9]{1,2}.*?GB|MB|KB' | out-null; $FastTierSizeReq80 = $matches[0]
            $info -match '[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}' | out-null; [string]$VolumeGuid = $matches[0]
            $Volume = get-volume | ? {$_.path -match $VolumeGuid}
            $VolumeName = $Volume.FileSystemLabel
            $volinfo = New-Object -TypeName PSObject -Property @{
                Date=$entrydate
                VolumeName=$VolumeName
                FastTierSize=$CurrentFastTierSize
                FastTierHitRate=$FastTierHitRate
                FastTierRequiredSize="$FastTierSizeReq100; $FastTierSizeReq90; $FastTierSizeReq80"
            }
            $TierStats += $volinfo
 
        }
        Return $TierStats
    }   
}
#endregion
 
 
#Remove Persistent Remote Session
#Write-Verbose "Removing WinRM Session"
#$PSSession | Remove-PSSession
 
 
#region output formatting
Write-Verbose "Constructing Output"
$Output = ""
$TableHdr = @"
<style>
BODY{background-color:white;}
TABLE{border-width: 1px;border-style: solid;border-color: grey;border-collapse: collapse;}
TH{border-width: 1px;padding: 4px;border-style: solid;border-color: grey;background-color:#000099;font-family:arial;font-size: 8pt; color: #FBFBEF;}
TD{border-width: 1px;padding: 4px;border-style: solid;border-color: grey;font-family:arial;font-size: 8pt; color: black;}
</style>
"@
 
 
 
$Output+="<html>
<body>
<font size=""2"" face=""Arial,sans-serif"">
<h2 align=""center"">Storage Spaces Report</h3>
<h3 align=""center"">Node: $StorageNode</h3>
<h5 align=""center"">Generated $((Get-Date).ToString())</h5>
</font>"
 
$output += "<html>
<body>
<font size=""3"" face=""Arial,sans-serif"">
<h3 align=""left"">Storage Pools</h3>
</font>"
$output += $StoragePoolInfo | ConvertTo-Html -Property FriendlyName,SizeGB,AllocatedGB,AllocatedPercent,EnclosureAwareDefault,IsClustered,OperationalStatus,HealthStatus -Head $TableHdr | Foreach {
    If ($_ -like "*<td>Healthy</td>*")
    {
        $_ -replace "<tr>", "<tr bgcolor=#CEF6CE>"
    }
    Else
    {
        $_ -replace "<tr>", "<tr bgcolor=#F6CEE3>"
    }
}
$Output += " "
 
$output += "<html>
<body>
<font size=""3"" face=""Arial,sans-serif"">
<h3 align=""left"">Virtual Disks ( $($VirtualDiskInfo.count) )</h3>
</font>"
$output += $VirtualDiskInfo | ConvertTo-Html -Property FriendlyName,StoragePool,ResiliencySettingName,NumberOfDataCopies,NumberofColumns,Interleave,IsEnclosureAware,SizeGB,WriteCacheSizeGB,IsTiered,SSDTierSizeGB,HDDTierSizeGB,OperationalStatus,HealthStatus -Head $TableHdr | Foreach {
    If ($_ -like "*<td>Healthy</td>*")
    {
        $_ -replace "<tr>", "<tr bgcolor=#CEF6CE>"
    }
    Else
    {
        $_ -replace "<tr>", "<tr bgcolor=#F6CEE3>"
    }
}
$Output += " "
 
 
$output += "<html>
<body>
<font size=""3"" face=""Arial,sans-serif"">
<h3 align=""left"">Storage Enclosures ( $($Enclosures.count) )</h3>
</font>"
$output += $Enclosures | Sort-Object FriendlyName | ConvertTo-Html -Property FriendlyName,UniqueId,SerialNumber,Firmware,Slots,HealthState,PowerSupplyState,FANState,IOControllerState,TemperatureSensorState -Head $TableHdr | Foreach {
    If ($_ -like "*<td>Healthy</td>*")
    {
        $_ -replace "<tr>", "<tr bgcolor=#CEF6CE>"
    }
    ElseIf ($_ -like "*<td>Unknown</td>*")
    {
        $_ -replace "<tr>", "<tr bgcolor=#FFFF99>"
    }
    Else
    {
        $_ -replace "<tr>", "<tr bgcolor=#F6CEE3>"
    }
}
$Output += " "
 
$output += "<html>
<body>
<font size=""3"" face=""Arial,sans-serif"">
<h3 align=""left"">Physical Disks ( $($PhysicalDiskInfo.count) )</h3>
</font>"
$output += $PhysicalDiskInfo | Sort-Object MediaType -Descending ConvertTo-Html -Property Name,Slot,Id,EnclosureID,Temperature,Mediatype,SizeGB,Manufacturer,Model,SerialNumber,FirmwareVersion,usage,OperationalState,HealthState,MaxReadLatency_ms,MaxWriteLatency_ms,PowerOnHours,TemperatureMax $TableHdr | Foreach {
    If ($_ -like "*<td>Healthy</td>*")
    {
        $_ -replace "<tr>", "<tr bgcolor=#CEF6CE>"
    }
    Else
    {
        $_ -replace "<tr>", "<tr bgcolor=#F6CEE3>"
    }
}
$Output += " "
 
If ($IncludeMPIO)
{
    $output += "<html>
    <body>
    <font size=""3"" face=""Arial,sans-serif"">
    <h3 align=""left"">MPIO Disk Path Info</h3>
    </font>"
    $output += $MPIOPathInfo ConvertTo-Html -Property Line | Foreach {
        If ($_ -like "*02 Paths*")
        {
            $_ -replace "<tr>", "<tr bgcolor=#CEF6CE>"
        }
        Else
        {
            $_ -replace "<tr>", "<tr bgcolor=#F6CEE3>"
        }
    }
    $Output += " "
}
 
If ($IncludeEvents)
{
    $output += "<html>
    <body>
    <font size=""3"" face=""Arial,sans-serif"">
    <h3 align=""left"">Storage Space Driver Events</h3>
    </font>"
    $output += $StorageSpaceDriverEvts ConvertTo-Html -Property TimeCreated,ID,LevelDisplayName,Message | Foreach {
        If ($_ -like "*<td>Warning</td>*")
        {
            $_ -replace "<tr>", "<tr bgcolor=#FFFF99>"
        }
        ElseIf ($_ -like "*<td>Error</td>*")
        {
            $_ -replace "<tr>", "<tr bgcolor=#F6CEE3>"
        }
        Else
        {
            $_ -replace "<tr>", "<tr bgcolor=#66CCFF>"
        }
    }
}
 
If ($IncludeTieringStats)
{
    $output += "<html>
    <body>
    <font size=""3"" face=""Arial,sans-serif"">
    <h3 align=""left"">Storage Tiering Statistics</h3>
    </font>"
    $output += $TieringStats ConvertTo-Html -Property Date,VolumeName,FastTierSize,FastTierHitRate,FastTierRequiredSize
 
}
 
if ($IncludeDedupStats){
 
 $output += "<html>
    <body>
    <font size=""3"" face=""Arial,sans-serif"">
    <h3 align=""left"">Deduplication Statistics</h3>
    </font>"
    $output += $DedupStatus ConvertTo-Html -Property Volume,Capacity,FreeSpace,SavingsRate,SavedSpace,UnoptimizedSize,UsedSpace,InPolicyFilesCount,InPolicyFileSize   
     
 
  $output += "<html>
    <body>
    <font size=""3"" face=""Arial,sans-serif"">
    <h3 align=""left"">Deduplication Events</h3>
    </font>"
    $output += $Dedupevents ConvertTo-Html -Property TimeCreated,ID,LevelDisplayName,Message | Foreach {
        If ($_ -like "*<td>Warning</td>*")
        {
            $_ -replace "<tr>", "<tr bgcolor=#FFFF99>"
        }
        ElseIf ($_ -like "*<td>Error</td>*")
        {
            $_ -replace "<tr>", "<tr bgcolor=#F6CEE3>"
        }
        Else
        {
            $_ -replace "<tr>", "<tr bgcolor=#66CCFF>"
        }
        }
     
   $output += "<html>
    <body>
    <font size=""3"" face=""Arial,sans-serif"">
    <h3 align=""left"">Deduplication Data Scrubbing</h3>
    </font>"
    $output += $DedupDiagevents ConvertTo-Html -Property TimeCreated,ID,LevelDisplayName,Message | Foreach {
        If ($_ -like "*<td>Warning</td>*")
        {
            $_ -replace "<tr>", "<tr bgcolor=#FFFF99>"
        }
        ElseIf ($_ -like "*<td>Error</td>*")
        {
            $_ -replace "<tr>", "<tr bgcolor=#F6CEE3>"
        }
        Else
        {
            $_ -replace "<tr>", "<tr bgcolor=#66CCFF>"
        }
        }
}
 
    If ($IncludeTieringStats)
{
    $output += "<html>
    <body>
    <font size=""3"" face=""Arial,sans-serif"">
    <h3 align=""left"">Storage Tiering Statistics</h3>
    </font>"
    $output += $TieringStats ConvertTo-Html -Property Date,VolumeName,FastTierSize,FastTierHitRate,FastTierRequiredSize
 
}
 
if ($IncludeReFSDebugEvents){
 
 $output += "<html>
    <body>
    <font size=""3"" face=""Arial,sans-serif"">
    <h3 align=""left"">ReFS Operational Events</h3>
    </font>"
    $output += $ReFSEvents ConvertTo-Html -Property TimeCreated,ID,LevelDisplayName,Message | Foreach {
        If ($_ -like "*<td>Warning</td>*")
        {
            $_ -replace "<tr>", "<tr bgcolor=#FFFF99>"
        }
        ElseIf ($_ -like "*<td>Error</td>*")
        {
            $_ -replace "<tr>", "<tr bgcolor=#F6CEE3>"
        }
        Else
        {
            $_ -replace "<tr>", "<tr bgcolor=#66CCFF>"
        }
        }
 
    $output += "<html>
    <body>
    <font size=""3"" face=""Arial,sans-serif"">
    <h3 align=""left"">Data Integrity Admin Events</h3>
    </font>"
    $output += $DataIntegrityAdmin ConvertTo-Html -Property TimeCreated,ID,LevelDisplayName,Message | Foreach {
        If ($_ -like "*<td>Warning</td>*")
        {
            $_ -replace "<tr>", "<tr bgcolor=#FFFF99>"
        }
        ElseIf ($_ -like "*<td>Error</td>*")
        {
            $_ -replace "<tr>", "<tr bgcolor=#F6CEE3>"
        }
        Else
        {
            $_ -replace "<tr>", "<tr bgcolor=#66CCFF>"
        }
        }
 
    $output += "<html>
    <body>
    <font size=""3"" face=""Arial,sans-serif"">
    <h3 align=""left"">Data Integrity Crash Debug Events</h3>
    </font>"
    $output += $DataIntegrityCrash ConvertTo-Html -Property TimeCreated,ID,LevelDisplayName,Message | Foreach {
        If ($_ -like "*<td>Warning</td>*")
        {
            $_ -replace "<tr>", "<tr bgcolor=#FFFF99>"
        }
        ElseIf ($_ -like "*<td>Error</td>*")
        {
            $_ -replace "<tr>", "<tr bgcolor=#F6CEE3>"
        }
        Else
        {
            $_ -replace "<tr>", "<tr bgcolor=#66CCFF>"
        }
        }
    }
 
 
If ($IncludeVMInfo)
{
    $output += "<html>
    <body>
    <font size=""3"" face=""Arial,sans-serif"">
    <h3 align=""left"">Hyper-V Titan Info </h3>
    </font>"
    $output += $VMInfo ConvertTo-Html -Property Name,State,CPUUsage,MemoryAssigned,Uptime,Status,Version
    If ($_ -like "*<td>Operating normally</td>*")
    {
        $_ -replace "<tr>", "<tr bgcolor=#CEF6CE>"
    }
    Else
    {
        $_ -replace "<tr>", "<tr bgcolor=#F6CEE3>"
    }
 
$Output += " "
     
    $output += "<html>
    <body>
    <font size=""3"" face=""Arial,sans-serif"">
    <h3 align=""left"">Hyper-V Replica Info </h3>
    </font>"
    $output += $VMReplicaInfo ConvertTo-Html -Property VMName,Name,Snapshottype,Creationtime,ParentSnapshotName
     
}
    #endregion
 
 
#Generate the output file
Write-Verbose "Writing Output to File $OutPutFile"
$output | Out-File $OutPutFile -Force
$emailbody = get-content $OutPutFile -Raw
 
#Openfile with default handler if switch is present
Write-Verbose "Opening Outputfile $OutPutFile"
If ($OpenFileAfterCreation)
{
    Invoke-Item  $OutPutFile
}
 
 
 
 
 
$Username ="username"
 
$Password = ConvertTo-SecureString "Passwordgoeshere" -AsPlainText -Force
 
$credential = New-Object System.Management.Automation.PSCredential $Username, $Password
 
$SMTPServer = "smtp.sendgrid.net"
 
$EmailFrom = "Titan-Operations-No-Reply@blah.com"
 
$EmailTo = "blah@blah.com"
 
$Subject = "Titan - Storage Spaces Report"
 
#$Body = "SendGrid testing successful"
 
#Mail the Report
#If ($MailTo -and $MailFrom -and $MailServer)
#Fore Mail to go with Hard Coded Parameters for now
    Send-MailMessage -From $EmailFrom -To $EmailTo -SmtpServer $SMTPServer -Credential $credential -Port 587 -Subject "Storage Spaces Report: $StorageNode" -Encoding UTF8 -BodyAsHtml -Body $output
 
 
#Send-MailMessage -smtpServer $SMTPServer -Credential $credential -Port 587 -from $EmailFrom -to $EmailTo -subject $Subject -Body $emailbody -BodyAsHtml
 
 
 
 
 
Write-Verbose "Report Created Successfully"

 

https://github.com/dkawula/Operations/blob/master/S2D/StorageSpacesReport-Titan.ps1

And a scheduled task if you want to automate this. The Schedule task will run if you create a local administrator service account. Even on the Storage Spaces Direct Nodes.

https://github.com/dkawula/Operations/blob/master/S2D/Titan%20Daily%20Health%20Report.xml

Now, I know the script isn’t perfect by any means but it does the job and even has a mailto function so that you can have this emailed to you on a triggered basis or as a daily health check report.

I hope you find this usefule and if you have ideas for improvements let’s collaborate via Github.

Thanks,


Dave