ONTAP Discussions

Using powershell to enabled scheduled snapshots


I can't seem to get scheduled snapshots enabled through powershell. I can assign a policy, but auto snapshots is not enabling, the below script says its sucessful, but the box remains unchecked and no snapshots are created. I tried setting nosnap directly but that says


Set-NcVolOption : Modification of the following fields: auto-snapshots-enabled not allowed for volumes of the type "Flexible Volume - Read-Write volume".

At line:1 char:1

+ Set-NcVolOption -Key "nosnap" -Value "off" -Name UCS_SAS_APP02_PROD01 ...

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

    + CategoryInfo          : InvalidOperation: ( [Set-NcVolOption], EONTAPI_EVOLOPNOTSUPP

    + FullyQualifiedErrorId : ApiException,DataONTAP.C.PowerShell.SDK.Cmdlets.Volume.SetNcVolOption


Is there a way to do this? Below is the code I'm using.


$vols=Get-NcVol | ?{
# get non-root volumes
$_.VolumeStateAttributes.IsNodeRoot -eq $false `
# which are rw (this will exclude SnapMirror, etc.)
$_.VolumeIdAttributes.Type -eq "rw" `
# with "nosnap" turned on
(($_ | Get-NcVolOption -Hashtable).value.nosnap -eq "on") `
# or with snapshot policy set to Target Policy
($_.VolumeSnapshotAttributes.SnapshotPolicy -eq "Daily_SS")

foreach($vol in $vols)
$query = @{
Name = $volName

$attributes = @{
VolumeSnapshotAttributes = @{
SnapshotPolicy = $policyName

$a=Get-NcVol -Template
Initialize-NcObjectProperty $a VolumeSnapshotAttributes


Update-NcVol -Query $query -Attributes $a





Disclaimer: I am not an expert on powershell stuff.


I think the "AutoSnapshotEnabled" property is set depending upon the policy.


If the policy is none -> AutoSnapshotEnabled = false
If the policy is set to say 'default' AutoSnapshotEnabled = True


Could you just try setting the 'policy' only, don't change anything else ?



I did that originally, I looked for any policy that was set to none, and change it the DAILY_SS polciy thats in the code. It looks like the policy did change, but no snapshots are being created and the box is unchecked in the gui. The odd thing is we have another cluster I did the same thing in and it seems to work there, but I'm not sure what I did to get it to apply correctly there.  Its the nosnap option in the volume that I can see change when I check the box in the gui, but powershell won't let me modify that directly for somereason.



Interesting case, I used this script to test mine. Attached here. We have some PS experts in the forums, they will know.


I think your example works because its going from a policy to a no policy, its trying to go from a non to a policy which I can't seem to do reliably. I think I did it at one point but I can't replicate it, like I mentioned before, it looks to have applied on one cluster, but our DR cluster I couldn't get it work in any of the methods I mentioned. I eneded up just enabling them manually but I'm very interested in the proper method.

NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner