Subscribe
Accepted Solution

Set-NaSnapshotAutodelete All Volumes

Hey Guys,

Struggling with this one, hoping this is an easy one for someone whos more adept with PowerShell than me. I want to set target_free_space across all volumes on a filer.. the below command works fine for individual ones:

Set-NaSnapshotAutodelete volname target_free_space 5

However I want to do this for all volumes, I have tried the below code

get-navol | Get-NaSnapshotAutodelete | Set-NaSnapshotAutodelete target_free_space 5

However this doesn't work, so tried this instead

$volume = get-navol

Set-NaSnapshotAutodelete $volume.name target_free_space 5

But this doesn't work either, what am I doing wrong? The error with he last one is

+ Set-NaSnapshotAutodelete $volume.name target_free_space 5

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidArgument: (:) [Set-NaSnapshotAutodelete], ParameterBindingException

    + FullyQualifiedErrorId : PositionalParameterNotFound,DataONTAP.PowerShell.SDK.Cmdlets.Aggr.SetNaSnapshotAutodelete

Re: Set-NaSnapshotAutodelete All Volumes

$volume variable is an array,

You need to pipe this array through a loop

$volume | % {

$name = $_.name

write-host "Setting autodelete for volume: " $name

set-NasnapshotAutodelete $name target_free_space 5

}

Re: Set-NaSnapshotAutodelete All Volumes

Try this

get-navol | % {Set-NaSnapshotAutodelete $_.name target_free_space 5} | Get-NaSnapshotAutodelete

Regards,

Vinith