Microsoft Virtualization Discussions

How to use Powershell to set the snapshot -snaplock-expiry-time ? Thanks!

ACWCalvinWong
1,475 Views
cluster1> volume snapshot create -vserver vs1 -volume vol1 -snapshot snap1 -snaplock-expiry-time "11/10/2022 09:00:00"

Example CLI as above I want to do it in Powershell way, thanks! 

1 ACCEPTED SOLUTION

TzwaynY
845 Views

Hey there, there is no native function in the Powershell Module atm. You have todo it via API. This is how I do it:

$VOLUMEURL = "https://NETAPPURL/api/storage/volumes/VOLUMEUUID/snapshots/SNAPSHOTUUID"
$RESPONSE = Invoke-RestMethod -Uri $VOLUMEURL -Method GET -Credential (Get-Credential) -SkipHeaderValidation -ErrorAction Stop -SkipCertificateCheck

$PAYLOAD = @{
  "snaplock_expiry_time" = "2069-06-04T19:00:00+00:00" #Edit this to the desired expiration
} | ConvertTo-Json

$RESPONSE = Invoke-RestMethod -Uri $VOLUMEURL -Method Patch -Body $PAYLOAD -Credential (Get-Credential) -SkipHeaderValidation -ErrorAction Stop -SkipCertificateCheck

$RESPONSE = Invoke-RestMethod -Uri $VOLUMEURL -Method GET -Credential (Get-Credential) -SkipHeaderValidation -ErrorAction Stop -SkipCertificateCheck

 

Please refer to the post I did prior to this:

https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Why-doesn-t-Set-NcSnapshotSnaplockExpTime-set-the-snapshot-snaplock-expiry/m-p/44...

 

Best regards

Kai

View solution in original post

1 REPLY 1

TzwaynY
846 Views

Hey there, there is no native function in the Powershell Module atm. You have todo it via API. This is how I do it:

$VOLUMEURL = "https://NETAPPURL/api/storage/volumes/VOLUMEUUID/snapshots/SNAPSHOTUUID"
$RESPONSE = Invoke-RestMethod -Uri $VOLUMEURL -Method GET -Credential (Get-Credential) -SkipHeaderValidation -ErrorAction Stop -SkipCertificateCheck

$PAYLOAD = @{
  "snaplock_expiry_time" = "2069-06-04T19:00:00+00:00" #Edit this to the desired expiration
} | ConvertTo-Json

$RESPONSE = Invoke-RestMethod -Uri $VOLUMEURL -Method Patch -Body $PAYLOAD -Credential (Get-Credential) -SkipHeaderValidation -ErrorAction Stop -SkipCertificateCheck

$RESPONSE = Invoke-RestMethod -Uri $VOLUMEURL -Method GET -Credential (Get-Credential) -SkipHeaderValidation -ErrorAction Stop -SkipCertificateCheck

 

Please refer to the post I did prior to this:

https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Why-doesn-t-Set-NcSnapshotSnaplockExpTime-set-the-snapshot-snaplock-expiry/m-p/44...

 

Best regards

Kai

Public