beardmann icon

Snapdrove powershell

beardmann | PRO | 04/21/15 01:19:24 PM UTC | 0 ⭐ | 341 👁️ | Never ⏰ | []
PowerShell |

800 B

|

None

|

0 👍

/

0 👎

function Remove-Snapshots()
{
  [CmdletBinding(SupportsShouldProcess=$true)]
  param
  (
    [Parameter(Mandatory=$true,Valuefrompipeline=$true)] $Volume,
    [string] $SnapName = "*",
    [int] $DaysOld = 5
  )
  begin
  {}
 
  process
  {
    foreach ( $vol in $Volume )
    {
      $volObj = $vol
      
      if ( $vol -is [string] )
      {
        #  If user provided a volume name as a string
        $volObl = Get-NaVol -Name $vol
      }
      
      $vol | Get-NaSnapshot | Where-Object -FilterScript { $_.Name -ilike $SnapName -and $_.Name -inotmatch "\.\d+?$" -and (New-TimeSpan -Start $_.AccesstimeDt).totalDays -gt $DaysOld } | Remove-NaSnapshot
    }
  }  
}
Import-Module dataontap
Connect-NaController controller1 -rpc
Get-NaVol | Remove-Snapshots
"vol1" | Remove-Snapshots

Comments