Microsoft Virtualization Discussions
Microsoft Virtualization Discussions
Solved! See The Solution
Hello @ahmada,
Here is one version, though you could do a rudimentary check beforehand to see if the number of snapshots taken at the desired time matches the number of volumes. If they don't match, then start looking for the volumes which are missing a snapshot.
# the reference time which we want to have a snapshot taken at # this will return an object referencing yesterday at 8pm $refTime = [DateTime]::Today.AddDays(-1).AddHours(20) # get only volumes with the snapshot policy we want Get-NcVol -Query @{ VolumeSnapshotAttributes = @{ SnapshotPolicy = "default" } } | ForEach-Object { # get snapshots for the volume which match the reference time if ( ($_ | Get-NcSnapshot | Where-Object { $_.AccessTimeDT -eq $refTime }).count -ne 1) { # if there wasn't one returned, state so in red Write-Host -ForegroundColor Red "Volume $($_.Name) does not have a snapshot at the reference time" } else { # there was one returned, say so in green Write-Host -ForegroundColor Green "Volume $($_.Name) has a snapshot at the reference time" } }
Note that this is for Clustered ONTAP. The 7-mode cmdlets used will be slightly different (I don't have a 7-mode system to test against), but the principle is the same.
Hope that helps.
Andrew
Hello @ahmada,
Here is one version, though you could do a rudimentary check beforehand to see if the number of snapshots taken at the desired time matches the number of volumes. If they don't match, then start looking for the volumes which are missing a snapshot.
# the reference time which we want to have a snapshot taken at # this will return an object referencing yesterday at 8pm $refTime = [DateTime]::Today.AddDays(-1).AddHours(20) # get only volumes with the snapshot policy we want Get-NcVol -Query @{ VolumeSnapshotAttributes = @{ SnapshotPolicy = "default" } } | ForEach-Object { # get snapshots for the volume which match the reference time if ( ($_ | Get-NcSnapshot | Where-Object { $_.AccessTimeDT -eq $refTime }).count -ne 1) { # if there wasn't one returned, state so in red Write-Host -ForegroundColor Red "Volume $($_.Name) does not have a snapshot at the reference time" } else { # there was one returned, say so in green Write-Host -ForegroundColor Green "Volume $($_.Name) has a snapshot at the reference time" } }
Note that this is for Clustered ONTAP. The 7-mode cmdlets used will be slightly different (I don't have a 7-mode system to test against), but the principle is the same.
Hope that helps.
Andrew
Thanks a lot worked like a charm 🙂
For some reason when I converted it for 7-mode '-eq' wasn't working as expected. I replaced it with '-gt' and had to settel to a snpashot named hourly.0 was taken yesterday
# the reference time which we want to have a snapshot taken at # this will return an object referencing yesterday at 8pm $refTime = [DateTime]::Today.AddDays(-1) $snapName = "hourly.0" $password = ConvertTo-SecureString "Netapp1!" -AsPlainText -Force $cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "root",$password #Connect to Filer Connect-NaController 192.168.1.212 -Credential $cred Get-NaVol| ForEach-Object { # get snapshots for the volume which match the reference time if ( ($_ | Get-NaSnapshot | Where-Object { $_.AccessTimeDT -gt $refTime -and $_.Name -eq $snapName }).count -ne 1) { # if there wasn't one returned, state so in red Write-Host -ForegroundColor Red "Volume $($_.Name) does not have a snapshot at the reference time" } else { # there was one returned, say so in green Write-Host -ForegroundColor Green "Volume $($_.Name) has a snapshot at the reference time" } }
Thanks again, your help made my day