77 Replies Latest reply: Apr 27, 2015 7:23 PM by Mark Iveli RSS

    PowerShell Module

    Justin Rich Adventurer

      jrich523/NimblePowerShell · GitHub

      Built and tested in Version 3 (v2 compatibility will be validated but it should be fine)

       

      Install

      Run the following line in PowerShell

      iex (new-object System.Net.WebClient).DownloadString('https://raw.github.com/jrich523/NimblePowerShell/master/Install.ps1')

       

      Load

      In powershell load the module by typing:

       

      Import-Module Nimble

       

      This might prompt for loading depending on what your execution policy is.

       

      To get a list of commands type:

       

      Get-Command -module Nimble

       

      currently the help files are not populated but once I get basic functionality up and running I'll start to sure up the code and populate help details.

       

       

      Examples

       

      ##Connect to array first, currently only handles one array

      Connect-NSArray -SystemName 192.168.1.55 -Password p@ssw0rd   ##currently password is just clear text, will change that soon


      #List volumes

      Get-NSVolume


      #New volume

      New-NSVolume -Name testvol -Size 1tb -Description "powershell test" -PerformancePolicy default



      #a more detailed example, assume you have a "clonetest" volume:


      Get-NSVolume

      Get-NSSnapShot -Volume clonetest

      Get-NSVolume -Name clonetest| New-NSSnapshot -Name CloneTest2 | New-NSClone -Name CloneTest2

      Get-NSSnapShot -Volume clonetest

      Get-NSVolume

      Get-NSVolume clonetest2 | Get-NSVolumeACL

      Get-NSInitiatorGroup

      Add-NSInitiatorGroupToVolume -InitiatorGroup esx -Volume clonetest2 -Access Volume

      Get-NSVolume clonetest2 | Get-NSVolumeACL

      Get-NSVolume clonetest2 | Get-NSVolumeACL | Get-NSInitiatorGroup

      Remove-NSVolume clonetest2 -Force

      Get-NSVolume clonetest | Get-NSSnapShot | Remove-NSSnapShot



      example.gif


      Requests

      If you have a special need let me know i can probably easily add it in, just trying to get base functionality and work towards replication the UI functionality.

       

      Message was edited by: Justin Rich module version 1.1 uploaded

        • Re: PowerShell Module
          Justin Rich Adventurer

          I have made some updates, mostly around docs so that cmdlets should have their help populated.

          Also I added some functions around the performance policy stuff.

          There will be a few more updates coming.

          • Re: PowerShell Module
            Jesse Hauf Newbie

            After running: Connect-NSArray -SystemName 192.168.1.55 -Password p@ssw0rd I get:

             

            Exception calling "getControllerName" with "1" argument(s): "Method 'getControllerName' not implemented: method name or namespace not recognized"

            At C:\Users\a_jesse\Documents\WindowsPowerShell\Modules\Nimble\Login.ps1:37 char:7

            +       $arrname = $script:nsunit.getControllerName($sid.value)

            +       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

                + FullyQualifiedErrorId : SoapHeaderException

             

            It does still connect to the array and I can add and remove volumes but I thought you might like to fix this.

             

            Otherwise I am very eager to see future development! This is great! Thanks!

            • Re: PowerShell Module
              Justin Rich Adventurer

              Interesting, what version of software are you running with your unit?

              • Re: PowerShell Module
                Casey Jones Newbie

                Hello Justin,

                 

                I am attempting to use a PS script to create multiple volumes on an array using this module. However, when attempting to set the performance policy name I receive errors. It appears that it does not like the spaces in the performance policy name. Please see the error below:

                 

                New-NSVolume : Cannot validate argument on parameter 'PerformancePolicy'. The argument "Exchange 2010 data store" does not belong to the set "default,DPM,'Exchange 2003 data store','Exchange 2007 data store','Exchange 2010 data store','Exchange log','Hyper-V CSV','Oracle OLTP',SharePoint,'SQL Server','SQL Server 2012','SQL Server Logs','VMware ESX','VMware ESX 5','VMware VDI','Windows File Server'" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again.

                At line:3 char:67 + New-NSVolume -Name $_.LunName -Size $_.LunSize -PerformancePolicy $_.Preformance ...

                 

                 

                Is there any way around this?

                 

                Thanks!

                • Re: PowerShell Module
                  Kevin Allen Newbie

                  Would it be possible to get a self-contained version (ZIP file) that could be installed via USB w/o Internet access?

                  • Re: PowerShell Module
                    Justin Rich Adventurer

                    you could also install it locally and then zip up the Nimble folder in your module folder inside your my documents. The advantage there is you dont get any of the unnecessary stuff

                    • Re: PowerShell Module
                      Jeff Wilson Newbie

                      This is incredible. Nice work Justin. How did you make such a beautiful animated gif?

                       

                      Oh the powershell module is cool too.

                       

                      Is your module signed?     Want to try this out.

                      • Re: PowerShell Module
                        Justin Rich Adventurer

                        Gifcam

                         

                        and no its not signed, i dont have the $300 to drop on a code signing cert... you're welcome to buy one for me

                        • Re: PowerShell Module
                          Justin Rich Adventurer

                          very cool, i'll have to check that out!

                          • Re: PowerShell Module
                            Mike Elam Wayfarer

                            I am working with Nimble PowerShell module, and am curious if it can allow you to work with volume collections? The volume that I am wanting to snap/clone has SQL Databases. I want to be able to have the snapshot VSS aware so the databases can be brought online in a good state. Any recommendations?

                             

                            Thanks,

                            • Re: PowerShell Module
                              Del Lee Newbie

                              When running the iex command in the original post, I get the error below.  Any clues as to what the problem is?

                               

                              The term 'param' is not recognized as the name of a cmdlet, function, script

                              file, or operable program. Check the spelling of the name, or if a path was in

                              cluded, verify that the path is correct and try again.

                              At line:1 char:9

                              + param <<<< ([string]$InstallDirectory)

                                  + CategoryInfo          : ObjectNotFound: (param:String) [], CommandNot

                                 FoundException

                                  + FullyQualifiedErrorId : CommandNotFoundException

                              • Re: PowerShell Module
                                andrew lass Newbie

                                I had to wrap the entire iex statement in an extra pair of parenthesis () to get it to work on Powershell latest and greatest on 2012 R2. This tells the compiler that anything inside of the first wrapper () is being used for iex. Whereas without the outer wrapper of () the compiler doesn't understand how to use the statement.

                                See below:

                                 

                                iex ((new-object System.Net.WebClient).DownloadString('https://raw.github.com/jrich523/NimblePowerShell/master/Install.ps1'))


                                I also want to give a shoutout to Justin for an incredible and easy-to-use way of accessing our Nimble arrays the Windows admin way. Thanks man, this is a great contribution to the communinity!


                                -Regards,

                                Andrew

                                • Re: PowerShell Module
                                  Keith Hensby-Peck Newbie

                                  Hi Justin

                                   

                                  Awesome plug-in - major life and time saver over the last 18 months!

                                   

                                  During a new green-field DC roll-out - I grabbed a copy of the V2 code published Jan 8th 2014 as the new array is 2.x (and the others we have are 1.4) - and tested against an array running 2.2.3.0-167018-opt (latest as of this date) firmware.

                                   

                                  There were several errors reported during login, Get-NSVolume and Snapping, so I dived into the code and made some minor changes to 3 of the PS1 files (login.ps1, Initiator.ps1 and Snap.ps1).

                                   

                                  The changes have all been noted in a fork in your GitHub release.. ( gitHub labelled this as patch-1 )   - hopefully I did this right - first time I have used GitHub  - so you can review them and approve if you're happy with them     ( If you want a zipped copy to compare against cause I messed the GH update up - let me know)

                                   

                                  So - basically, the module is now running again on the latest array firmware and the latest OS revision :

                                   

                                  Test Environment:

                                       CS300 Array - running firmware 2.2.3.0-167018-opt

                                       2 x Windows 2012 R2 Server with Nimble WIT v2.2.3.432 installed (both physical and VM-direct assigned iscsi)

                                   

                                  Tests Achieved / Working:

                                       Connect-NSServer

                                       Get-NSVolume

                                       Get-NSSnapshot

                                       Get-NSInitiatorGroup

                                       Get-NSPerfPolicy TestVol

                                       Get-NSVolume | GetNSPerfPolicy

                                       Add-NSInitiatorGroupToVolume "TestVol" "TestServ" "Both"

                                       Get-NSVolume -name "TestVol" | New-NSsnapshot -name "Testsnap"

                                       Get-NSVolume -name "TestVol" | get-nssnapshot | select -first 1 | New-NSClone -name "TestClonedVol"  ( Takes latest snap from a Prot Group and clones it to a volume for mounting on the backup server ! )

                                       Add-NSInitiatorGroupToVolume "TestVol" "TestServ" "Both"

                                       Add-NSInitiatorGroupToVolume "TestClonedVol" "BackupServ" "Both"

                                       $NewVol = New-NSVolume -Name $NewDiskName.ToString() -Size $NewDiskSize -Description "New Volume" -PerformancePolicy $NewDiskPerf

                                   

                                  There are more tests to do : I'll update the GH if there are any other snags found.

                                   

                                  Cheers dude.

                                   

                                  Keith.

                                    • Re: PowerShell Module
                                      Kelley Underwood Newbie

                                      We are running 2.2.5.0-197583-opt and I've setup the latest versions of the PowerShell script but I cannot get the New-NSVolume command to work. I'm trying something like this: New-NSVolume -Name TestDB -Size 200gb -PerformancePolicy "Exchange 2010 data store". I get this error below. This happens even if I enter default without quotes for the Performance Policy. If I enter New_NSVolume by itself and provide answers the prompts, I also get an error on the value 200gb. Is this due to an incompatibility with the new software or am I doing this wrong?

                                       

                                      Thanks for any assistance.

                                       

                                      New-NSVolume : Error Creating volume TestDB code: SMeinval

                                      At line:1 char:1

                                      + New-NSVolume -Name TestDB -Size 200gb -PerformancePolicy "Exchange 2010 da ...

                                      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                                          + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException

                                          + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,New-NSVolume

                                      • Re: PowerShell Module
                                        Kelley Underwood Newbie

                                        Would you or anyone else have one or more script samples you could share? I'm looking for a way to script the creation of an initiator group, volume collections with verification and new volumes for the collection. My initial intent is to simplify building multiple new Exchange Servers with over 50 volumes each. I've been able to create a new volume but am struggling with the other issues.

                                          • Re: PowerShell Module
                                            Justin Rich Adventurer

                                            If you run

                                             

                                            Get-Command -module nimble

                                             

                                            you'll get a list of commands, you'll see there is a New-NSInitiatorGroup and Add-NSInitiatorToGroup etc

                                            Most of these have some basic documentation.

                                             

                                            As far as the volume collection stuff thats what im working on now (Have run in to some issues with the API)

                                             

                                            If you want to test/verify these you're best option is to run the Get-NS* commands to see if the object you created exists, however I will say i've never come across a time in which the cmd was successful but it didnt do what it was suppose to.

                                             

                                            If something doesnt work as you'd expect, or you'd like a new feature please submit it on the github site

                                            • Re: PowerShell Module
                                              Mark Iveli Newbie

                                              Kelley Underwood,

                                               

                                              Here is my script that i have just written. It has been tested and it worked but it needs more testing. It isnt perfect and has lots of room for improvement.

                                               

                                              What we are doing is cloning 3 drive to 3 new drive on the same server (dont ask...).

                                               

                                              ## This script could be setup on Server1 or from another server that has the nimble powershell module installed

                                              #running the script locally will not require any credentials to be stored in the script (except for the nimble account)

                                               

                                               

                                              ## Remove a disk from Windows

                                              Write-Host "Finding the partitions that were created last week" -ForegroundColor Cyan

                                               

                                              set-disk -Number 14 -IsOffline $true

                                              set-disk -Number 15 -IsOffline $true

                                              set-disk -Number 16 -IsOffline $true

                                               

                                              #Nimble Array connection Variable

                                              Write-Host "setting Nimble Variables to connect to array" -ForegroundColor Cyan

                                              $user="NimblePSUser"

                                              $pw="Password"

                                              $array="Array IP"

                                              $igroup = "IgroupName"

                                               

                                              ##Connect to array first, currently only handles one array

                                              Write-Host "Connecting you now....."

                                              Connect-NSArray -SystemName $array -UserName $user -Password $pw

                                               

                                              ## Remove a Volume from Nimble. Need some form of check and confirm before continuing

                                              Write-Host "Deleting the old clones for Server1 in preparation for the new data refresh" -ForegroundColor Yellow

                                              Remove-NSVolume -Name Clone-Server1-Q-drive -Confirm:$false

                                              Remove-NSVolume -Name Clone-Server1-W-drive -Confirm:$false

                                              Remove-NSVolume -Name Clone-Server1-U-drive -Confirm:$false

                                               

                                              ##Remove the oldest snapshot (should be snapshot number 2)

                                              Write-Host "Snapshot housekeeping on the Array. Deleting the oldest snapshot" -ForegroundColor Yellow

                                              remove-nssnapshot -SnapName VDWWeeklyDataRefreshTest -Volume t1-ap-nimble-vol060-Server1-G-drive -Confirm:$false

                                              remove-nssnapshot -SnapName IMSWeeklyDataRefreshTest -Volume t1-ap-nimble-vol061-Server1-J-drive -Confirm:$false

                                              remove-nssnapshot -SnapName CDWWeeklyDataRefreshTest -Volume t1-ap-nimble-vol063-Server1-L-drive -Confirm:$false

                                               

                                              #Refresh the iSCSi Target list

                                              Write-host "Updating iSCSI target list..."

                                              Update-IscsiTarget

                                               

                                               

                                              ## take a snapshot of a volume

                                              Write-Host "New snapshots being generated on the Array for this weeks data refresh" -ForegroundColor Yellow

                                              $VDW = Get-NSVolume -name t1-ap-nimble-vol060-Server1-G-drive | New-NSSnapshot VDWWeeklyDataRefreshTest -Online:$false -Writable:$false

                                              $IMS = Get-NSVolume -name t1-ap-nimble-vol061-Server1-J-drive | New-NSSnapshot IMSWeeklyDataRefreshTest -Online:$false -Writable:$false

                                              $CDW = Get-NSVolume -name t1-ap-nimble-vol063-Server1-L-drive | New-NSSnapshot CDWWeeklyDataRefreshTest -Online:$false -Writable:$false

                                               

                                               

                                              ## clone the snapshot into the volumes includes naming the volume

                                              Write-Host "New Volume Clones being generated from the most recent snapshots" -ForegroundColor Yellow

                                               

                                              $VDWClone = Get-NSSnapShot -SnapName 'VDWWeeklyDataRefreshTest' | New-NSClone -Name "Clone-Server1-Q-drive" -Verbose

                                              $IMSClone = Get-NSSnapShot -SnapName 'IMSWeeklyDataRefreshTest' | New-NSClone -Name "Clone-Server1-W-drive" -Verbose

                                              $CDWClone = Get-NSSnapShot -SnapName 'CDWWeeklyDataRefreshTest' | New-NSClone -Name "Clone-Server1-U-drive" -Verbose

                                               

                                              ##Add initiator group to a volume

                                              Write-Host "presenting the new volumes to correct initiator group" -ForegroundColor Yellow

                                              Add-NSInitiatorGroupToVolume -InitiatorGroup $igroup -Volume $VDWClone

                                              Add-NSInitiatorGroupToVolume -InitiatorGroup $igroup -Volume $IMSClone

                                              Add-NSInitiatorGroupToVolume -InitiatorGroup $igroup -Volume $CDWClone

                                               

                                              ## Rescan the windows disks for new volume.

                                              Write-Host "refreshing the iscsi target list with the new cloned volumes"-ForegroundColor Yellow

                                              Update-IscsiTarget

                                               

                                              #Connectting the iSCSI disks

                                              Get-IscsiTarget -NodeAddress "iqn.2007-11.com.nimblestorage:clone-Server1-q-drive-*" | Connect-IscsiTarget -IsPersistent:$true

                                              Get-IscsiTarget -NodeAddress "iqn.2007-11.com.nimblestorage:clone-Server1-u-drive-*" | Connect-IscsiTarget -IsPersistent:$true

                                              Get-IscsiTarget -NodeAddress "iqn.2007-11.com.nimblestorage:clone-Server1-w-drive-*" | Connect-IscsiTarget -IsPersistent:$true

                                               

                                              Write-Host "rescanning for iSCSI Targets" -ForegroundColor Yellow

                                              Get-IscsiTarget -NodeAddress iqn.2007-11.com.nimblestorage:clone-Server1* | fl

                                              "rescan" | diskpart

                                               

                                              sleep 15

                                               

                                              #Set Cloned disk to Writable

                                              Write-host "Setting disk in Write Mode..."

                                               

                                              get-disk -Number '14' | set-disk -IsReadOnly:$false

                                              get-disk -Number '15' | set-disk -IsReadOnly:$false

                                              get-disk -Number '16' | set-disk -IsReadOnly:$false

                                               

                                              #Set Cloned disk to Online

                                              Write-host "Setting disk to Online..."

                                              get-disk -Number '14' | set-disk -IsOffline:$false

                                              get-disk -Number '15' | set-disk -IsOffline:$false

                                              get-disk -Number '16' | set-disk -IsOffline:$false

                                               

                                              ## add and initiate a new volume as a drive letter

                                              Write-Host "adding the new cloned volume in a partitions with the correct drive letter" -ForegroundColor Yellow

                                              set-Partition -DiskNumber '14' -PartitionNumber '2' -NewDriveLetter Q

                                              set-Partition -DiskNumber '15' -PartitionNumber '2' -NewDriveLetter W

                                              set-Partition -DiskNumber '16' -PartitionNumber '2' -NewDriveLetter U

                                               

                                              # Set the Disk label

                                              Write-host "Changing the disk label....."

                                              Set-Volume -DriveLetter Q -newFileSystemLabel "Weekly VDW Data Refresh"

                                              Set-volume -DriveLetter W -newFileSystemLabel "Weekly IMS Data Refresh"

                                              Set-Volume -DriveLetter U -newFileSystemLabel "Weekly CDW Data Refresh"

                                                • Re: PowerShell Module
                                                  Mark Iveli Newbie

                                                  Kelley Underwood

                                                   

                                                  Also, some things that i found during this work...

                                                   

                                                  the new-nsvolume command has some trouble with creating new volumes where the name is a certain length. Not sure what that length is but during my work i wanted to use Clone-ap-nimble-vol060-Server1-G-drive but it would throw a wierd SMEintval error.

                                                  In the ## clone the snapshot into a new volume section (line 54), using the Get-NSSnapShot -SnapName $VDW doesnt work and i have had to explicity name the snapshot. You can remove the variables from the #Take a snapshot of a volume section.

                                                  Also i would like to see if someone could help write a module to rename a snapshot. We want to keep a few snapshot for recover purposes so renaming the snapshot would be cool.

                                                   

                                                  And i would like to get some other things added to this script such as;

                                                   

                                                  error checking

                                                  more logic to make sure it selects the right disks to present or delete. Right now it works and it is solid but if we add a new disk to the server then we need to update all of the disk number in the script.

                                                  Getting some form of HTML report created so we can send this to the Data owners and IT support on the weekly schedule.

                                                   

                                                  If you have any recommendations for other improvements please share. I am still working on this as well and if i can get past some of these items i will also update.