Microsoft Virtualization Discussions

Set-NaSnapshotAutodelete All Volumes

DAMIANGILL

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

Try this

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

Regards,

Vinith

View solution in original post

2 REPLIES 2

vinith

Try this

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

Regards,

Vinith

View solution in original post

JGPSHNTAP

$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

}

Announcements
Register for Insight 2021 Digital

INSIGHT 2021 Digital: Meet the Specialists 2

On October 20-22, gear up for a fully digital, totally immersive virtual experience with a downright legendary lineup of world-renowned specialists. Tune in for visionary conversations, solution deep dives, technical sessions and more.

NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner
Public