NetApp Community Update
This site will enter Read Only mode on July 23 as we prepare to move to a new platform. You will still be able to view content, but posting and replying will be temporarily disabled.
We're excited to launch our new Community experience on July 30 and more information will follow soon.
Stay connected during the transition - Join our Discord community today.

Microsoft Virtualization Discussions

Powershell command for adding existing snapshot policy to a volume -

NwkThd_04
4,240 Views

Hello Team, 

 

Anyone please help me to find the command  for adding  existing snapshot policy to a volume 

 

I have tried with  " get-ncvol volume name  -Vserver  vserver name   |  Set-NcSnapshotPolicy   policy name" but failed 

 Also  I was trying  update-ncvol  as well , but could not  find snapshotpolicy name option there.

it looks like I am not using the current context?

I am using powershell tool kit 9.8.xx 

Thanking you in advance.

 

Regards,

 

Shyju.

2 REPLIES 2

ajeffrey
4,151 Views

Hi There

I was able to get this to work but only after creating a snapshot policy with a scope of the particular Storage VM

Screen Shot 2021-07-02 at 10.55.11 AM.png

PS C:\Users\Administrator> Get-NcVol -Vserver FP-Test | Set-NcSnapshotPolicy -Name test

Policy Enabled SnapshotPolicySchedules
------ ------- -----------------------
test True {hourly (0), daily (0), weekly (1)}
test True {hourly (0), daily (0), weekly (1)}
test True {hourly (0), daily (0), weekly (1)}
test True {hourly (0), daily (0), weekly (1)}
test True {hourly (0), daily (0), weekly (1)}
test True {hourly (0), daily (0), weekly (1)}
test True {hourly (0), daily (0), weekly (1)}
test True {hourly (0), daily (0), weekly (1)}
test True {hourly (0), daily (0), weekly (1)}
test True {hourly (0), daily (0), weekly (1)}
test True {hourly (0), daily (0), weekly (1)}

rafael-miranda
1,594 Views

Hello. I don't mean to necropost, but since I had the same need and didn't find a comprehensive answer, here's an example that worked using "Update-NcVol" with version 9.15.1.2410 of the NetApp.ONTAP module.

 

# The $querytemplate variable will be used to specify which volumes should be modified. The example specifies a specific vserver and a simple regex to match 3 volume names. You can change this to suit your environment.
$querytemplate = Get-NcVol -Template
$querytemplate.Vserver = "vserver-name"
$querytemplate.Name = "vol1|vol2|vol3"

# The $attrib variable will specify the snapshot policy to be set on the volumes that match the criteria defined in the $querytemplate variable.
$attrib = Get-NcVol -Template
Initialize-NcObjectProperty -Object $attrib -Name VolumeSnapshotAttributes
$attrib.VolumeSnapshotAttributes.SnapshotPolicy = "snap_policy"

# This will effectively change the snapshot policy on the volumes. The '-ONTAPI' parameter is used so that ZAPI is used instead of the REST API, which is the default in this version of the module.
Update-NcVol -Query $querytemplate -Attributes $attrib -ONTAPI

 

Public