NetApp Community Update
This site will enter Read Only mode on July 23 as we prepare to move to a new platform. You will still be able to view content, but posting and replying will be temporarily disabled.
We're excited to launch our new Community experience on July 30 and more information will follow soon.
Stay connected during the transition - Join our Discord community today.

ONTAP Discussions

Powershell Get-NaSnapshotAutodelete

kmancy
3,947 Views

Hi,

Does anyone jnow how I can get the value for 'state' from the commandlet Get-NaSnapshotAutodelete?

With other commandlets i can just do this.

$Autogrow = Get-NaVolAutosize $volume.Name
              $AutogrowOn = $Autogrow.IsEnabled.

I just want the value for 'state' (which is on or off). The output from the CLI is

PS > Get-NaSnapshotAutodelete $volume.Name

OptionName                                                                                                        OptionValue                                                                                                    
----------                                                                                                        -----------                                                                                                    
state                                                                                                             on                                                                                                             
commitment                                                                                                        try                                                                                                            
trigger                                                                                                           volume                                                                                                         
target_free_space                                                                                                 20                                                                                                             
delete_order                                                                                                      oldest_first                                                                                                   
defer_delete                                                                                                      user_created                                                                                                   
destroy_list                                                                                                      none            

Thanks

3 REPLIES 3

doug_clendening
3,947 Views

You ever figure out how to get "state" value from snapshot autoddelete?

doug.clendening@chemailto:doug.clendening@chemailto:doug.clendening@chevron.com

bgentile1
3,947 Views

Try this:

get-nasnapshotautodelete $volume.name|%{$sadresult += @{$_."optionname"=$_."optionvalue"}}

Then your results will be in a hash called $sadresult so you can do

$sadresult.state

patrick_digirolamo
3,947 Views

This will get the snapshot autodelete values for all volumes. This was bugging me for a while.

$volumes = Get-Navol

foreach ($volume in $volumes) {

$TheVolumeName = $volume.Name

$autodeletes = @(Get-nasnapshotautodelete $TheVolumeName | select OptionName, OptionValue)

write-host $TheVolumeName,"***"$autodeletes[0].optionvalue,"***"$autodeletes[1].optionvalue,"***"$autodeletes[2].optionvalue,"***"$autodeletes[3].optionvalue,"***"$autodeletes[4].optionvalue,"***"$autodeletes[5].optionvalue,"***"$autodeletes[6].optionvalue,"***"$autodeletes[7].optionvalue

}

Public