Array Setup and Networking
1827857 Members
1754 Online
109969 Solutions
New Discussion

PowerShell Module

 
jrich52352
Trusted Contributor

Re: PowerShell Module

I hope to have the V2 module released soon. Waiting for the devs to get back to me on some volume collection stuff, been having a hard time getting that to work.

miveli
New Member

Re: PowerShell Module

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"

miveli
New Member

Re: PowerShell Module

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.

tpope7
New Member

Re: PowerShell Module

I'm having issues logging to Nimble via PS. Any ideas:

PS P:\> Connect-NSArray -SystemName 192.168.1.80 -Username [MYUSERNAME] -Password [MYPASSWORD]
Exception calling "getGroupConfig" with "2" argument(s): "There is an error in XML document (2, 1417)."
At C:\Users\tpope\Documents\WindowsPowerShell\Modules\Nimble\Login.ps1:38 char:7
+ $arrname = $script:nsunit.getGroupConfig($script:sid.value,[ref]$err).grou ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException

Logged into array @

If I do not specify my username I get this:

PS P:\> Connect-NSArray -SystemName 192.168.1.80
cmdlet Connect-NSArray at command pipeline position 1
Supply values for the following parameters:
Password: ********
Couldn't login to http://192.168.1.80:4210/soap

Has anyone else come across this? I appear to have successfully imported the module:

PS P:\> Import-Module Nimble

PS P:\> Get-Command -module Nimble

CommandType Name ModuleName
----------- ---- ----------
Function Add-NSInitiatorGroupToVolume Nimble
Function Add-NSInitiatorToGroup Nimble
Function Connect-NSArray Nimble
Function Get-NSArray Nimble
Function Get-NSInitiatorGroup Nimble
Function Get-NSPerfPolicy Nimble
Function Get-NSSnapShot Nimble
Function Get-NSVolume Nimble
Function Get-NSVolumeACL Nimble
Function Get-NSVolumeCollection Nimble
Function New-NSClone Nimble
Function New-NSInitiatorGroup Nimble
Function New-NSPerfPolicy Nimble
Function New-NSSnapshot Nimble
Function New-NSVolume Nimble
Function Remove-NSInitiatorFromGroup Nimble
Function Remove-NSInitiatorGroup Nimble
Function Remove-NSSnapShot Nimble
Function Remove-NSVolume Nimble
Function Set-NSVolumeState Nimble

markshannon
Established Member

Re: PowerShell Module

hi

is it possible to take a nimble snapshot and add it to a volume collection at the same time so the snap is managed?

thanks

mark