Microsoft Virtualization Discussions

Trying to list schedules for all volumes enabled

ABARTHELMORT
3,770 Views

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

4 REPLIES 4

JGPSHNTAP
3,770 Views

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

JGPSHNTAP
3,770 Views

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

ABARTHELMORT
3,770 Views

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.

wim_van_der_heijden
3,770 Views

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

}

Public