Microsoft Virtualization Discussions

PSTK 9.11.1 usage of wildcard in get-snapshot

Migo
1,348 Views

I found a strange behaviour when listing snapshots with Get-NcSnapshot.  Can anyone spot my mistake?

Basically, I try to build a script that modifies snapmirror-labels on all Snapshots containing a certain text string in their name.

This was the script I tried: Get-NcSnapshot -SnapName *sometext* -Volume * | Set-NcSnapshot -SnapmirrorLabel yearly

Since this did not work, I tried it manually:

 

So I connect to the cluster and an SVM with:

Connect-NcController -Name testcluster -Vserver int-nv001-nfs1

 

Then I run:

Get-NcSnapshot -Volume * 

This only returns Snapshots from the Vserver root Volume

 

If I run:

Get-NcSnapshot -Volume nfs*

It returns only Snapshots from a Volume called nfs_vdi001_data1 (although there are other Volumes called "nfs_vdi001_data2" and "nfs_vmware001_data1" etc. in the same Vserver)

 

If I run:

Get-NcSnapshot -Volume nfs_vmware* or Get-NcSnapshot -Volume nfs_vmware001_data*

It returns only Snapshots from Volume nfs_vmware001_data1 (although there are other Volumes called "nfs_vmware001_data2", "nfs_vmware001_data3" etc.in the same Vserver)

 

If I run: 

Get-NcSnapshot -Volume nfs_vmware001_data2

It returns only Snapshots from Volume nfs_vmware001_data2 (as expected)

 

Target Cluster is ONTAP 9.11.1P4

1 ACCEPTED SOLUTION

Migo
1,201 Views

For those interested, I tried Powershell Toolkit Version  9.8.0 (DataONTAP not NetApp.ONTAP) and the script works flawlessly. 


Somehow, something has changed in the way PSTK uses ONTAP wildcards here, although the documentation suggests the use of ONTAP wildcards is possible.

View solution in original post

3 REPLIES 3

Ontapforrum
1,327 Views

Could you check this command, if this helps. I don't have setup handy to test this.

 

Get-NcSnapshot -Volume * | where-object {$_ -like "*nfs*" }

and

Get-NcSnapshot -Volume * | where-object {$_ -like "*nfs*" } | Select Name,Volume,Vserver,SnapmirrorLabel

Migo
1,325 Views

Those return nothing, probably because in the root volume, there are no Snapshots containing "nfs".

 

PS C:\Windows\system32> Get-NcSnapshot -Volume *

Name Volume Vserver Created Total Cumulative Dependency
---- ------ ------- ------- ----- ---------- ----------
weekly.2022-11-27_0015 svm_nfs_vmware001... int-nv001-nfs1 27.11.2022
weekly.2022-12-04_0015 svm_nfs_vmware001... int-nv001-nfs1 04.12.2022

daily.2022-12-08_0010 svm_nfs_vmware001... int-nv001-nfs1 08.12.2022

...

 

However it the where-object does work:

PS C:\Windows\system32> Get-NcSnapshot -Volume * | where-object {$_ -like "*weekly*" } | Select Name,Volume,Vserver,SnapmirrorLabel

Name Volume Vserver SnapmirrorLabel
---- ------ ------- ---------------
weekly.2022-11-27_0015 svm_nfs_vmware001_root int-nv001-nfs1 weekly
weekly.2022-12-04_0015 svm_nfs_vmware001_root int-nv001-nfs1 weekly

Migo
1,202 Views

For those interested, I tried Powershell Toolkit Version  9.8.0 (DataONTAP not NetApp.ONTAP) and the script works flawlessly. 


Somehow, something has changed in the way PSTK uses ONTAP wildcards here, although the documentation suggests the use of ONTAP wildcards is possible.

Public