Data ONTAP Discussions

Powershell Get-NaSnapshotAutodelete


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            



Powershell Get-NaSnapshotAutodelete

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

Re: Powershell Get-NaSnapshotAutodelete

Try this:

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

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


Re: Powershell Get-NaSnapshotAutodelete

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