Thursday, January 23, 2014

Find volumes without autodelete or autosize enabled

powershell script to loop through each of the filers looking for any VMnfs volume which did not have the autosize enabled and was not able to autogrow


import-module dataontap
$results= @()
$filers = "Filer1","Filer2","Filer3","Filer4","Filer5","Filer6"
$filers | foreach-object {
    write-host $_
    connect-nacontroller $_
    $vmvols = get-NaVol | Where-Object { ($_.name -like "*vmnfs*" -or $_.name -like "*vmwaredata*" -or $_.name -like "*VDI*" ) -and -not ($_.name -like "*m" -or $_.name -like "*m2" -or $_.name -like "*page" -or $_.name -like "*srmph"  -or $_.name -like "*swap" -or $_.name -like "*sw" -or $_.name -like "*vdi*" -or $_.name -like "*NonProd" -or $_.name -like "*filer1vmnfsvolsyslog"  -or $_.name -like "*filer2vmnfsvolvdisys"  -or $_.name -like "*filer3vmnfsvol0*") }
    foreach ($volume in $vmvols) {
        $VolumeName=$volume.name
        $volumeSize=$volume.SizeTotal
        $VolumeSizeAvailable=$volume.SizeAvailable
        $autogrow = Get-NaVolAutosize -name $volume
        $AutogrowEnabled = $autogrow.isenabled
        $SnapshotAutodelete = Get-nasnapshotautodelete $volume
        }

        If  (($AutogrowEnabled -notlike "true" ) -or ($SnapshotAutodelete[4].OptionValue -notlike "on") )
        {

       
        $results += New-Object psobject -Property @{
                                       
                                        'Volume' = $volume
                                        'AutogrowEnabled' = $autogrowEnabled
                                        'SnapshotAutodelete' = $SnapshotAutodelete[4].OptionValue
                                       }
       }
}


No comments:

Post a Comment