Microsoft Virtualization Discussions

Get-NcSnapshot does not return a single snapshot

MAMMANN
1,956 Views

I'm trying to create a script to add Snapmirror-Labels to snapshots that don't have one.

Although i'm able to get a list of snapshots by Get-NcSnapshot, selecting a single snapshot by this command runs to a "operation timed out".


-PowerShell ToolKit Version 9.11.1.2208

-Cluster/Ontap Version 9.10.1P7

-OS: Windows 10 22H2

Running the command as follows

Get-NcSnapshot -Volume nfs_vmware3_vault | Select Name,Volume,Vserver,SnapmirrorLabel

returns a proper list:

Name Volume Vserver SnapmirrorLabel
---- ------ ------- ---------------
VeeamSnapVault_nfs_vmware3_monthly.2021-11-01_0001 nfs_vmware3_vault svm-nfs-dr
VeeamSnapVault_nfs_vmware3_monthly.2021-12-01_0001 nfs_vmware3_vault svm-nfs-dr
...
VeeamSnapVault_nfs_vmware3_monthly.2022-09-01_0001 nfs_vmware3_vault svm-nfs-dr
VeeamSnapVault_nfs_vmware3_monthly.2022-10-01_0001 nfs_vmware3_vault svm-nfs-dr

trying to fetch a single object of these:

Get-NcSnapshot -Volume nfs_vmware3_vault -SnapName VeeamSnapVault_nfs_vmware3_monthly.2022-10-01_0001 | Select Name,Volume,Vserver,SnapmirrorLabel

runs into a timeout:

Get-NcSnapshot : The operation has timed out
At line:1 char:1
+ Get-NcSnapshot -Volume nfs_vmware3_vault -SnapName VeeamSnapVault_nfs ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-NcSnapshot], ArgumentException
+ FullyQualifiedErrorId : The operation has timed out,DataONTAP.C.PowerShell.SDK.Cmdlets.Snapshot.GetNcSnapshot

as of this, i'm not able so set a snapmirror label by "Set-NcSnapShot -snapmirrorlabel "xy"...

am i doing something wrong or is this a bug?

3 REPLIES 3

Ontapforrum
1,931 Views

Ok. I haven't used powershell for some time now and I don't have it installed, so I am not sure if that works. But I googled and found 'where-object', this might give you the result, give this a try:

Sample:

Get-NcSnapshot -Volume nfs_vmware3_vault | Where-Object {$_.Name -eq "VeeamSnapVault_nfs_vmware3_monthly.2022-10-01_0001"} | Select Name,Volume,Vserver,SnapmirrorLabel

MAMMANN
1,917 Views

Hi,

in fact, i don't get the error message anymore. Interestingly, this somehow still doesn't work.
I changed my code as follows:

function Tag-Snapshot($Snap){
    If ($Snap.Name -like "*daily*"){
        Write-Log -Info "Found tag 'daily' in Snapshot $Snap Setting its SnapMirror-Label accordingly" -Status Info
        Get-NcSnapshot -Volume $Snap.Volume | ?($_.Name -eq $Snap.Name) | Set-NcSnapShot -SnapmirrorLabel "daily"
    }
}

I now don't get a timeout anymore, unfortunately the snapmirrorlabel does not get set without any error message....

AmmarMhowwala
1,799 Views

Hi,

I had tried on my side with below

-PowerShell ToolKit Version 9.11.1.2208

-Cluster/Ontap Version 9.10.1P7

Every thing is working fine in my side.

  • Multiple Snapshot:-

Get-NcSnapshot -Volume bunny3 | Select Name,Volume,Vserver,SnapmirrorLabel

Name Volume Vserver SnapmirrorLabel
---- ------ ------- ---------------
daily.2022-12-04_0010 bunny3 vs1 daily
weekly.2022-12-04_0015 bunny3 vs1 weekly
hourly.2022-12-05_0005 bunny3 vs1
daily.2022-12-05_0010 bunny3 vs1 daily
hourly.2022-12-05_0105 bunny3 vs1
hourly.2022-12-05_0205 bunny3 vs1
hourly.2022-12-05_0305 bunny3 vs1
hourly.2022-12-05_0405 bunny3 vs1
hourly.2022-12-05_0505 bunny3 vs1

  • Single Snapshot :-

Get-NcSnapshot -Volume bunny3 -SnapName hourly.2022-12-05_0305 | Select Name,Volume,Vserver,SnapmirrorLabel

Name Volume Vserver SnapmirrorLabel
---- ------ ------- ---------------
hourly.2022-12-05_0305 bunny3 vs1

  • Setting snapmirror label

Get-NcSnapshot -Volume bunny3 -SnapName hourly.2022-12-05_0305 | Select Name,Volume,Vserver,SnapmirrorLabel | Set-NcSnapshot -SnapmirrorLabel "Hourly" | Select Name,Volume,Vserver,SnapmirrorLabel

Name Volume Vserver SnapmirrorLabel
---- ------ ------- ---------------
hourly.2022-12-05_0305 bunny3 vs1 Hourly

I think operation time out is might be due to network issue

Public