ONTAP Discussions

Powershell Get-NaSnapshotAutodelete

kmancy
2,994 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
2,994 Views

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

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

bgentile1
2,994 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
2,994 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