Microsoft Virtualization Discussions

Set-NaSnapshotAutodelete All Volumes

DAMIANGILL
3,106 Views

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

1 ACCEPTED SOLUTION

vinith
3,106 Views

Try this

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

Regards,

Vinith

View solution in original post

2 REPLIES 2

JGPSHNTAP
3,106 Views

$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

}

vinith
3,107 Views

Try this

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

Regards,

Vinith

Public