Community

Subscribe
Highlighted

Trying to list schedules for all volumes enabled

Hello all,

I'm trying to list the snapshot schedules for all volumes that have snapshots currently enabled.

I used a simple get-navol | get-nasnapshotschedule | export-csv -path c:\snapshots.csv to try and attempt this but have noticed it is dumping all volumes (as expected) but is not showing if scheduled snapshots are enabled or not.

I'm wondering if anyone has any ideas how I could get the schedule for only those volumes with scheduled snapshots enabled.

Thanks,

Adam

Re: Trying to list schedules for all volumes enabled

I have a full dashboard that will do this, but I will get you started

$snapsched = Get-NaSnapshotSchedule $volume -erroraction "silentlycontinue"
 

 
  if ($snapsched.weeks -eq 0 -and $snapsched.days -eq 0 -and $snapsched.hours -eq 0 -and $snapsched.minutes -eq 0) {
  $snapshotsched = "No"
  } else {
  $snapshotsched = "Yes"

  }

Write-host $snapshotsched  - This will tell you if there is a snapshot schedule

But

Re: Trying to list schedules for all volumes enabled

The other thing is it's easy to remove stuff from the pipeline, so we can find the volumes easily that don't have a schedule associated

get-navol |get-nasnapshotschedule |  ? {($_.days -eq 0) -and ($_.hours -eq 0) -and ($_.Weeks -eq 0)}

But are all your vol options nosnap set to on or you just control it through the schedule.  I was trying to craft something via one pipeline, but i think the if/else will have to do the trick

Re: Trying to list schedules for all volumes enabled

Thank you for your assistance.  Theoretically nosnap should be set "on" on the volumes with out snapshots but I will go through and check that as well.

Re: Trying to list schedules for all volumes enabled

Maybe this is something you want:

if you change

$snapsched = Get-NaSnapshotSchedule $volume -erroraction "silentlycontinue

to
$snapscheds = get-navol | Select-Object -Property @{n='targetname';e={$_.Name}} | Get-NaSnapshotSchedule

followed with:

foreach ($snapsched in $snapscheds) {

     if ($snapsched.weeks -eq 0 -and $snapsched.days -eq 0 -and $snapsched.hours -eq 0 -and $snapsched.minutes -eq 0) {
     $snapshotsched = "No"
     } else {
       $snapshotsched = "Yes"

     }

Write-host $snapshotsched  - This will tell you if there is a snapshot schedule

}