Microsoft Virtualization Discussions

Volume Snapshot Policy

tomers
3,710 Views

Hi Guys, 

using Ontap PS toolkit i can get the snapshot policy for a volume.

i need to get the amount of days in that policy.

 

So when i use this command:

(Get-NcSnapshotPolicy)[0].SnapshotPolicySchedules

i get the following output:

Count : 14
NcController : nadrp1
Prefix : daily
Schedule : daily
SnapmirrorLabel : -
CountSpecified : True

Count : 24
NcController : nadrp1
Prefix : hourly
Schedule : hourly
SnapmirrorLabel : -
CountSpecified : True

 

i want to ask if (Schedule is daily) and get the Count field.

but because count is a build in command in every powershell array, when i use count (ie: (Get-NcSnapshotPolicy)[0].SnapshotPolicySchedules.count  ) i get the count of rows in the array and NOT the '14' value i expect.

 

any idea ?

 

 

Thanks, 

Tomer Shoshan.

1 REPLY 1

tomers
3,703 Views

Hi, 

so i had overcome this in some way but its not idle

 

does anyone have any other idea ?

 

my current resolution  is:

 

$CurrParentPolicy = (Get-NcSnapshotPolicy | where {$_.Policy -like $CurrParentVol.VolumeSnapshotAttributes.SnapshotPolicy}).SnapshotPolicySchedules | Where  {$_.Schedule -like 'day*' -or $_.Schedule -like 'daily*'}

 

because i found out that if you filter it this deep,  when you run "$CurrParentPolicy.count" it will return the array count filed (and not the build in command)

 

 

 

so if you run:

$CurrParentPolicy

you get this result:

 

Count : 14
NcController : nadrp1
Prefix : daily
Schedule : daily
SnapmirrorLabel : -
CountSpecified : True

 

and when you run $CurrParentPolicy.Count

you get 14

 

 

Tomer.

 

Public