General

Volume mapping and LUN associations with Dell Storage PowerShell Command Set

I wrote this script sample for someone who was interested in managing their failover with Sync Live Volume, but wanted to get a high-level view of mappings including LUN information and WWNs ahead of time so they could compare that information across arrays and prevent conflicts as they worked out their disaster recovery plan.  Dell Storage Manager obviously has this information, but having it in a format in one place is convenient, and putting it in CSV format adds some flexibility.

This script uses the Compellent PowerShell Command Set (version 7.1.2.1) which is available for customers to download from the Compellent Knowledge Center.  This script was designed specifically for the Command Set and won’t work with the newer Dell Storage PowerShell SDK which was released late last year.

For our implementation, we followed these steps:

  1. Make a connection to the Storage Center with the provided credentials.  We don’t store the password in the script, instead we prompt for it on execution.
  2. We retrieve all of the mappings on the Storage Center with the Get-SCVolumeMap cmdlet.
  3. We then iterate through the mappings and create a custom psobject containing the info we need.  This gives us the flexibility to use standard cmdlets for formatting and display.
  4. We output the psobject array with a format-table command.
  5. Optionally, we can output the psobject array to a CSV for further review and customization.

Here is the finished product:

# Copyright (c) 2008-2016 Justin Braun. All rights reserved.
#
# 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.
#
# DESC: PowerShell script to list all volume mappings including their server, LUN, 
# 		associated controller WWN, and server WWN. (Optional: uncomment last line
#		to output data to CSV.)
#
# NOTE: Developed and tested with Compellent PowerShell Command Set Version 7.1.2.1.
#		This script is not compatible with the Dell Storage PowerShell SDK.
#


# Check if Compellent.StorageCenter.PSSnapin is loaded
If ( ! (Get-PSSnapin -name Compellent.StorageCenter.PSSnapin )) {
	Add-PSSnapin Compellent.StorageCenter.PSSnapin
	Write-Host "Compellent.StorageCenter.PSSnapin loaded."
}

# Setup Storage Center credentials
$scname = "<StorageCenterHostnameOrIPAddress>"
$scusername = "<Username>"
$scpassword = Read-Host "Please enter your password" -AsSecureString

# Create Storage Center connection object
$conn = Get-SCConnection -HostName $scname -User $scusername -Password $scpassword

if (!$conn) {
	Write-Host "Invalid connection or connection doesn't exist.  Halting script."
	Exit
}

# Get all mappings
$mappings = Get-SCVolumeMap -Connection $conn

# Check if there are mappings found
if(!$mappings) {
	Write-Host "Mappings could not be retrieved or no mappings exist.  Halting script."
	Exit
}

# We have mappings, so create array to store a custom info object about each mapping
$report = @()

# Iterate through mappings
foreach($mapping in $mappings)
{
	# Create custom object to store mapping info about each mapping
	$report += New-Object psobject -Property @{
			ServerName = $mapping.ServerName
			VolumeName = $mapping.VolumeName
			LUN = $mapping.LUN
			ControllerWWN = $mapping.ControllerWWN
			ServerWWN = $mapping.ServerWWN
		}
}

# Output to console all information about the mappings
$report | sort VolumeName,ServerName,LUN | ft VolumeName,ServerName,LUN,ServerWWN,ControllerWWN

# Output to CSV all information about the mappings
# $report | sort VolumeName,ServerName,LUN | select VolumeName,ServerName,LUN,ServerWWN,ControllerWWN | Export-Csv "c:\temp\mappings.txt"

Write-Host "Script complete!"

Sample output: