Virtualization Articles and Resources

Automate Creation of New V-Servers with Powershell with ls mirrors


I have been working on some scripts to allow the rapid creation of vservers where we can also create ls mirrors on all nodes.

Here is what I have come up with so far.

I have set this up using a text file with one or more vservers to create first line is required.




# The script assumes import-module dataontap ; connect-nccontroller mycluster

$vservers = import-csv vservers.csv

$vservers | foreach {

new-ncvserver -name $ -RootVolume $($"_root") -RootVolumeAggregate $_.rootvolumeaggregate -NameServerSwitch $_.NameServerSwitch -RootVolumeSecurityStyle $_.RootVolumeSecurityStyle -NameMappingSwitch $_.NameMappingSwitch -Language $_.Language


#Query the Cluster and look for aggr1 to add the ls mirror to that aggreagate

$q = Get-NcAggr -Template

$q.Name = "*aggr1*"

#Loop through the vservers

#Loop through the aggregates queried

#Append _ls to the Name of the root volume

#remove dashes in the name

# I static set the volume size to 100m

$vservers | foreach {

if ($_.Create_ls -eq $true){

foreach ($ag in (Get-NcAggr -Query $q).name){

$lsvs = $ + "_" + (Get-NcAggr $ag).nodes.replace("-","_") + "_LS"

new-ncvol -Name $lsvs -Size 100m -Type dp -Aggregate $ag  -JunctionPath $null -VserverContext $ | out-null

New-NcSnapmirror -Source ("//" + $ + "/" + $($"_root")) -Destination ("//" + $ + "/" + $lsvs-Type LS |Set-NcSnapmirror -Schedule 5min |out-null


# After all mirrors have been added initialize the mirrors

Invoke-NcSnapmirrorLsInitialize ("//" + $ + "/" + $($"_root"))




Please Note:

All content posted on the NetApp Community is publicly searchable and viewable. Participation in the NetApp Community is voluntary.

In accordance with our Code of Conduct and Community Terms of Use, DO NOT post or attach the following:

  • Software files (compressed or uncompressed)
  • Files that require an End User License Agreement (EULA)
  • Confidential information
  • Personal data you do not want publicly available
  • Another’s personally identifiable information (PII)
  • Copyrighted materials without the permission of the copyright owner

Continued non-compliance may result in NetApp Community account restrictions or termination.

All Community Forums