PowerShell Script – Capture Storage Spaces Tier Optimization Job Output For Trending

Just a quick script bit I wanted to share that helps producing a trending report of the SSD hit ratio in a tiered space over time using information from the Windows Event log for Storage Tiering. String parsing could be prettier but it does the job 😉 To export to a csv, simply pipe the output of the script to Export-Csv. I will post the script to https://gemautomation.codeplex.com/ in the next release soon.

$volumes=Get-Volume | Select FileSystemLabel,ObjectId
foreach($clusterNode in $clusterNodes)
    $optimizationEvents=Get-WinEvent -ComputerName $clusterNode -LogName "Microsoft-Windows-Storage-Tiering/Admin" | where {$_.ID -eq 22}

    foreach($optimizationEvent in $optimizationEvents)
        $volumeOptimizationStatistics+=New-Object PSObject -Property @{ OptimizationDate=$optimizationEvent.TimeCreated
                                                                        VolumeLabel=($volumes | where {$_.ObjectId -eq $volumeId.Replace("??","\?")})[0].FileSystemLabel;
                                                                        PercentServicedFromSSD=($optimizationEvent.Message -split '[\r\n]')[29].Substring(50,3) -replace '%','';


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s