Creating a Storage Virtual Machine for SMSP/SharePoint (Part 1)

I thought I would share a Windows PowerShell script that I use to create my Storage Virtual Machines (SVM) for Microsoft SharePoint Server and SnapManager for SharePoint (SMSP). This script uses the Data ONTAP PowerShell Toolkit 2.4 with Clustered Data ONTAP to create all the different objects related to a SVM. I create a lot of different SVMs throughout a given week and automating the process is quite handy so one does not have to step through the NetApp OnCommand System Manager wizard all the time. There is nothing special in this script that makes it only for SMSP/SharePoint so this could be customized and used for any SVM creation. I will be adding in Part 2 the script to create Volumes and LUNs that follow our latest NetApp Best Practices in TR-4193 for SMSP/SharePoint.

 

 

# +---------------------------------------------------------------------------

# | File : LodCreateSMSPSVM.ps1

# | Version : 1.00                                      

# | Purpose :

# | Synopsis:

# | Usage : .\LodCreateSMSPVSM.ps1

# +----------------------------------------------------------------------------

# | Maintenance History                                           

# | --------------------                                           

# | Name               Date         Version  C/R Description       

# | ----------------------------------------------------------------------------------

# | Rob Barker         2013-05-30   1.00 Script originated for new SharePoint 2013/SMSP 7.1.1 lab.

# |

# +-------------------------------------------------------------------------------

# ********************************************************************************

 

# Variables

Param

(

$svm = 'SMSP_SVM'

, $aggr1 = 'aggr1_02'

, $aggr2 = 'aggr2_02'

, $rootvol = 'SMSP_root'

, $node1 = 'cluster1-01'

, $node2 = 'cluster1-02'

, $domain = 'demo.netapp.com'

, $node1iscsilif1 = 'cluster-01-iscsi_if1'

, $node1iscsilif2 = 'cluster-01-iscsi_if2'

, $node2iscsilif1 = 'cluster-02-iscsi_if1'

, $node2iscsilif2 = 'cluster-02-iscsi_if2'

, $mgmtlif = 'SMSP_SVM_mgmt'

, $node1cifslif = 'SMSP_SVM_cifsnfs_if1'

, $node2cifslif = 'SMSP_SVM_cifsnfs_if2'

)

 

# Connect to SIMBOX

Connect-NcController 192.168.0.101  -Credential(Get-Credential) -HTTPS

 

# Get current information from cluster

Get-NcVserver

Get-NcAggr

Get-NcVol

Get-NcLun

Get-NcNetInterface

 

# Create a new Storage Virtual Machine (Vserver)

New-NcVserver -Name $svm -RootVolumeAggregate $aggr1 -RootVolume $rootvol -NameServerSwitch file -RootVolumeSecurityStyle ntfs -NameMappingSwitch file

 

# Configure our lifs

New-NcNetInterface -Name $node1iscsilif1 -Vserver $svm -Role data -Node $node1 -Port e0c -Address 192.168.0.131 -Netmask 255.255.255.0 -FirewallPolicy data -DataProtocols "iscsi"

New-NcNetInterface -Name $node1iscsilif2 -Vserver $svm -Role data -Node $node1 -Port e0d -Address 192.168.0.132 -Netmask 255.255.255.0 -FirewallPolicy data -DataProtocols "iscsi"

New-NcNetInterface -Name $node2iscsilif1 -Vserver $svm -Role data -Node $node2 -Port e0c -Address 192.168.0.133 -Netmask 255.255.255.0 -FirewallPolicy data -DataProtocols "iscsi"

New-NcNetInterface -Name $node2iscsilif2 -Vserver $svm -Role data -Node $node2 -Port e0d -Address 192.168.0.134 -Netmask 255.255.255.0 -FirewallPolicy data -DataProtocols "iscsi"

New-NcNetRoutingGroupRoute -Vserver $vsm -Destination 0.0.0.0/0 -Gateway 192.168.0.1 -RoutingGroup d192.168.0.0/24

Set-NcNetInterface -Name $node1iscsilif1 -Vserver $svm -RoutingGroup d192.168.0.0/24

Set-NcNetInterface -Name $node1iscsilif2 -Vserver $svm -RoutingGroup d192.168.0.0/24

Set-NcNetInterface -Name $node2iscsilif1 -Vserver $svm -RoutingGroup d192.168.0.0/24

Set-NcNetInterface -Name $node2iscsilif2 -Vserver $svm -RoutingGroup d192.168.0.0/24

New-NcNetInterface -Name $node1cifslif -Vserver $svm -Role data -Node $node1 -Port e0e -Address 192.168.0.135 -Netmask 255.255.255.0 -FirewallPolicy data -DataProtocols "cifs" -RoutingGroup "d192.168.0.0/24"

New-NcNetInterface -Name $node2cifslif -Vserver $svm -Role data -Node $node2 -Port e0e -Address 192.168.0.136 -Netmask 255.255.255.0 -FirewallPolicy data -DataProtocols "cifs" -RoutingGroup "d192.168.0.0/24"

New-NcNetInterface -Name $mgmtlif -Vserver $svm -Role data -Node $node1 -Port e0e -Address 192.168.0.130 -Netmask 255.255.255.0 -FirewallPolicy mgmt -DataProtocols "none" -RoutingGroup "d192.168.0.0/24"

 

# Create the export policy

New-NcExportPolicy -Name full-access -VserverContext $svm

New-NcExportPolicy -Name ro-access -VserverContext $svm

New-NcExportPolicy -Name denied-access -VserverContext $svm

 

# Assign rules to our policy

New-NcExportRule -Policy default -ClientMatch 0.0.0.0/0 -ReadOnlySecurityFlavor any -ReadWriteSecurityFlavor any -VserverContext $svm

New-NcExportRule -Policy full-access -ClientMatch 0.0.0.0/0 -ReadOnlySecurityFlavor sys -ReadWriteSecurityFlavor sys -Anon 0 -SuperUserSecurityFlavor sys -VserverContext $svm

New-NcExportRule -Policy ro-access -ClientMatch 0.0.0.0/0 -ReadOnlySecurityFlavor sys -ReadWriteSecurityFlavor sys -Anon 0 -SuperUserSecurityFlavor sys -VserverContext $svm

New-NcExportRule -Policy denied-access -ClientMatch 0.0.0.0/0 -ReadOnlySecurityFlavor never -ReadWriteSecurityFlavor never -VserverContext $svm

 

# Configure DNS

Set-NcNetDns -Domain $domain -NameServers 192.168.0.253 -State enabled -VserverContext $svm

 

# Add Storage Virtual Machine to domain. When prompted login with the domain administrators account password.

Add-NcCifsServer -Name $svm -Domain $domain -OrganizationalUnit CN=Computers -AdminCredential administrator -VserverContext $svm

 

# Create user to group mappings

Invoke-ncssh -Command "vserver services unix-user create -vserver $svm -user pcuser -id 65534 -primary-gid 65534"

Invoke-ncssh -Command "vserver services unix-user create -vserver $svm -user root -id 0 -primary-gid 1"

Invoke-ncssh -Command "vserver services unix-group create -vserver $svm -name pcuser -id 65534"

Invoke-ncssh -Command "vserver services unix-group create -vserver $svm -name root -id 0"

Invoke-ncssh -Command "vserver name-mapping create -vserver $svm -direction win-unix -position 1 -pattern DOMAIN\\Administrator -replacement root"

Invoke-ncssh -Command "vserver name-mapping create -vserver $svm -direction unix-win -position 1 -pattern root -replacement DOMAIN\\Administrator"

Set-NcCifsOption -DefaultUnixUser pcuser -VserverContext $svm

 

# Enable iSCSI

Enable-NcIscsi -VserverContext $svm

Add-NcIscsiService -VserverContext $svm

 

@NaSharePointGuy

Comments
Occasional Contributor

Very groovy Mr.B.

Cheers.....