CompellentDevelopmentPowerShell

Compellent Volume Reporting with PowerShell

Compellent Enterprise Manager works great for managing your Storage Center environment and providing reports on volume usage and utilization.

I was looking for a little different spin on the information.  I was looking for a cumulative volume count across an entire Storage Center, plus a total count of replays on the system, and how many of the volumes that exist are actually mapped up to a server object.

For example, the test system that I ran my script on determined that we had over 900 volumes with over 3,000 replays.  We also realized that we had some cleanup to do when we figured out that only 180 of the volumes were actually mapped up.

I did build into the script to collect the page count of each replay so you could tell how large they were if you wanted to; just the calculation needs to be added.

# NAME: VolumeInfo.ps1
# DESC: PowerShell script to report on volume information
# BY  : Justin Braun, Compellent Technologies, Inc.
# DATE: December 1, 2009
# VER : 1.0
#
# 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.
#
# NOTE: This script assumes a default Get-SCConnection already exists.
 
# Collection
$colVolumes = @()
 
foreach($volume in Get-SCVolume)
{
    Write-Host "Gathering volume data for $volume.Name..."
    
    $replays = $null
    $mappings = $null
    $pagecount = 0
    
    # Volume Information
    $ReportData = New-Object System.Object
    $ReportData | Add-Member -Type NoteProperty -Name "Volume Index" -Value $volume.Index
    $ReportData | Add-Member -Type NoteProperty -Name "Volume Name" -Value $volume.Name
    $ReportData | Add-Member -Type NoteProperty -Name "Volume Size" -Value $volume.Size
    $ReportData | Add-Member -Type NoteProperty -Name "Block Count" -Value $volume.BlockCount
    $ReportData | Add-Member -Type NoteProperty -Name "Created By" -Value $volume.CreateUser
    $ReportData | Add-Member -Type NoteProperty -Name "Created On" -Value $volume.CreateTime
    $ReportData | Add-Member -Type NoteProperty -Name "Modified By" -Value $volume.ModifyUser
    $ReportData | Add-Member -Type NoteProperty -Name "Modified On" -Value $volume.ModifyTime
    $ReportData | Add-Member -Type NoteProperty -Name "Folder" -Value $volume.ParentFolder
    
    # Replay Count Information
    Write-Host "Gathering replay information for $volume.Name..."
    $replays = Get-SCReplay -SourceVolumeIndex $volume.Index
    $ReportData | Add-Member -Type NoteProperty -Name "Replay Count" -Value $replays.Count
    
    # Replay Cumulative Page Information
    Write-Host "Gathering replay page count information for $volume.Name..."
    foreach($replay in $replays)
    {
        $pagecount += $replay.OwnedPageCount
    }
    
    $ReportData | Add-Member -Type NoteProperty -Name "Total Replay Pages" -Value $pagecount
    
    # Volume Mapping Information
    Write-Host "Gathering volume mapping information for $volume.Name..."
    $mappings = Get-SCVolumeMap -VolumeIndex $volume.Index
    
    if($mappings -eq $null)
    {
        $ReportData | Add-Member -Type NoteProperty -Name "Mappings" -Value "No"
    }
    else
    {
        $ReportData | Add-Member -Type NoteProperty -Name "Mappings" -Value "Yes"
    }
    
    # Add to collection
    $colVolumes += $ReportData
    
}
 
# Outfile ReportData Contents
Write-Host "Writing output file..."
 
$colVolumes | export-csv -path "c:\volumeinfo.txt"
 
Write-Host "Done!"

If you have any ideas on how this script could be more useful in your environment, drop me a comment below.