Dell Storage Volume Cleanup with PowerShell
If you’re new to PowerShell with Dell Storage, be sure to take a look at this post. Depending upon the size of system that your managing, over the course of time, you might have experienced some challenges in managing disk resources, especially if you’re using an array in a lab-type environment.
Here’s an easy way to inventory volume objects on your SC Series array which are not currently mapped, and also find out how much actual space they’re consuming.
This script uses the Dell Storage PowerShell SDK. We’ll highlight the main calls used to get the information. This example doesn’t cover error handling or import of the PowerShell module for the Dell Storage PowerShell SDK.
Useful function
The ConfiguredSpace and ActualSpace properties return a Size type which is really a string with numbers and the measurement type, either MB, GB, TB, or PB. This can make it difficult to sort columns by size when needing to do so by number vs. string.
This function converts those columns to megabytes and returns an integer based on what string is passed in. Then you can create a column that contains the integer and sort by that while displaying the string property.
[wc_box color=”warning” text_align=”left”]
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.
[/wc_box]
function ConvertConfiguredSize ($cs) { $str = $cs -split "\s+" # Convert all values to MB switch ($str[1]) { "GB" { return ([int]$str[0]*1024*100000)/100000 } "TB" { return (([int]$str[0]*1048576*100000)/100000) } "MB" { return [int]$str[0] } default { return "N/A" } } }
function ConvertConfiguredSize ($cs) { $str = $cs -split "\s+" # Convert all values to MB switch ($str[1]) { "GB" { return ([int]$str[0]*1024*100000)/100000 } "TB" { return (([int]$str[0]*1048576*100000)/100000) } "MB" { return [int]$str[0] } default { return "N/A" } } }
Getting unmapped volumes
There is a “mapped” property that can be used to return a boolean value, which makes it easy to get a list of volumes that aren’t “in use”.
Once we have the volume list, we build a custom object with properties for both the configured space and actual space of the volume. We get that information through a couple of new cmdlets associated with “storage usage”.
$vollist = Get-DellScVolume -ConnectionName $emname | where { $_.mapped -eq $false } $volreport = @() # Iterate through mappings foreach($vol in $vollist) { # Get Storage Usage $suassoc = Get-DellScVolumeStorageUsageAssociation $vol -ConnectionName $emname $usage = Get-DellScVolumeStorageUsage $suassoc -ConnectionName $emname # Create custom object to store mapping info about each mapping $volreport += New-Object psobject -Property @{ VolumeName = $vol.InstanceName ConfiguredSpaceMB = ConvertConfiguredSize $usage.ConfiguredSpace ConfiguredSpaceStr = $usage.ConfiguredSpace ActualSpaceMB = ConvertConfiguredSize $usage.ActualSpace ActualSpaceStr = $usage.ActualSpace } } $volreport | sort @{Expression="ActualSpaceMB";Descending=$true} | select VolumeName,ActualSpaceStr
Here’s what the output looks like:
Conclusion
You can now get a report of unmapped volumes and the amount of actual disk space on each being consumed. There are additional properties that can be exposed to provide information on RAID overhead and replay consumption.
Hi Justin,
Your blog is helping me a lot to handle my Compellent storage using powershell.
May i know is there any way i can have performance/usage reports created using any method of automation by using the SQL DB ? I know we can get such reports from Enterprise Manager, But I am planning to exporting the DB in to another server and planning to create some more performance reports out of it. Thanks, Murali
Thanks! As far getting some of the performance and usage statistics, a lot of that information is available by using the REST API which has a PowerShell SDK. There is a ton of data that is available from that, and the REST API is basically the replacement for the existing PowerShell Command Set. Check out the Compellent PowerShell Cookbook for some examples on how to use it. You can find it here: http://en.community.dell.com/techcenter/extras/m/white_papers/20441893.