Dell Storage Volume Cleanup with PowerShell

Posh1
By: Justin Braun
Posted on: May 25, 2016

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:

posh1

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.

Related Articles

Posh1

PowerShell Scripting Options for Dell Storage

Back in 2008, Compellent released their first iteration of the PowerShell Command Set.
code, coding, computer

Python 101: Pulling the weather forecast with the NWS API

Although Python might be a 30-year-old programming language, it's an easy language to adopt, provide

Discovering Stale Computer Accounts with PowerShell

We all know that most test domains are the perfect breeding ground for non-standard practices.