Start a Conversation

Unsolved

This post is more than 5 years old

3777

November 21st, 2011 11:00

Powershell - Add additional mappings for existing server

This post has been copied from the former Compellent User Forum and placed here for your reference.  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.

Add additional mappings for existing server – Originally posted By thedoc31, 22 Feb 2011

thedoc31 - Recently I discovered that our existing VMWare ESXi implementation didn't have MPIO set up properly.  I've followed the VMware guide to bind a specific IP address to a specific vmkernel port, assigned it an additional IP, and scanned it on the Compellent to make sure it sees the additional initiators.  

On our VMWare farm that is connected to Storage Center 5.0, I was easily able to add the additional mappings to the new vmkernel port and all the mappings came along with it, but on Storage Center 4.5, I had to add the mappings for each LUN manually to the server.  Kind of a pain when there are 20+ LUNs for each VMware host.

So, I decided to write a script that enumerates all existing LUNs and sorts them by LUN number, then loops through each LUN and adds the additional mappings automatically.  Any maps that already exist are skipped and show up as harmless warnings.  This script could be easily modified to do any of a number of repetitive tasks. 

I had to include the connection info for each command to work - would love to clean this up with any suggestions you might have.

# -----------------------------

$server = "SERVERNAME"

$volumes = get-scvolumemap -connection $connection -servername $server | select-object -property LUN,VolumeName | sort-object LUN | get-unique -asstring

foreach ($item in $volumes)

{

New-SCVolumeMap -connection $connection (Get-SCVolume -connection $connection -Name $item.VolumeName) (Get-SCServer -connection $connection -Name $server)

}

Hope it helps some of you out there....

No Responses!
No Events found!

Top