Create a new Equallogic volume via PowerShell

I have been playing around with Powershell, and thought I would write a basic little function to create a new volume.

Function eqlNewVol
{
param ([string]$grpName,[string]$volname, [decimal]$gb, [string]$strPool, [string]$VolumeDesc, [bool]$tp) 
write-debug "Beginning Script, calling new-eqlvolume"
write-debug "$grpname, $volname, $gb, $strpool, $VolumeDesc, $tp"

new-eqlvolume -groupname $grpname -volumeName $volname `
-volumesizeMB ($gb * 1048576) `
-storagepoolname $strPool `
-AllowMultipleInitiators $True `
-Volumedescription $VolumeDesc `
-thinprovision $tp 
write-debug "new-eqlvolume called"

#Add permissions from a file called c:\initiators.csv
write-debug "Setting permissions"
(get-content c:\initiators.csv) `
| foreach-object {new-eqlvolumeACL -volumeName $volname –InitiatorName $_ -AclTargetType volume_and_snapshot}
}

Basically, it will take command line arguments to create a new volume, and then add initiators based on name, taken from a file called c:\initiators.csv.

You would probably want to connect first, when you can do with the “connect-eqlgroup” command, you can then call the function using something like this:

eqlNewVol MySANGroup, NewVol1, 1.95, myPool, 0

First though, you need to load the function to make it accessible. If the function is stored in (say) myfunctions.ps1, you will need to load this (. ./myfunctions.ps1) before you can call it. Not that dot space dot forwardslash file syntax.

Oh, and you will of course need the the Equallogic powershell plugin’s.

Advertisements

1 Comment

Filed under Equallogic, Powershell

One response to “Create a new Equallogic volume via PowerShell

  1. Lee Olett

    Thanks, Saves a lot of time!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s