# 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!"