Legacy Product Discussions


Please help in writing a Powershell script to delete all backups from a server


I am fairly new to the whole powershell/netapp domain.

The idea is to list the available backups on the server and then delete all of them for we use cloning to get the most recent snapshots of SQL databases. There is simply no need to older data. As far as I understand, the loop will go through each component of the get-backup array and try to delete it, failing on one will result going to the next, and that is what we are looking for.

So I was trying something like:

get-backup -server ourserver -serverinstance -ourserverinstance; delete-backup

I get the following:

cmdlet delete-backup at command pipeline position 1

Supply values for the following parameters:



How do I do wild cards here? Thanks


Re: Please help in writing a Powershell script to delete all backups from a server

I finally figured it out. The script is below. First, we have to download, install and load the Data ONTAP Powershell Toolkit (http://communities.netapp.com/docs/DOC-8111?REF_SOURCE=tot-1010&h).

Next, create a function to connect to a na controller and delete all snaps which are not busy. You would need an admin-level account and password. Last, execute the function against related volumes.

--defining function

function nas
{param ($vol)
$User  = "admin-level account"
$Pass  = ConvertTo-SecureString "pass for the account" -AsPlainText –Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User,$Pass
Connect-NaController -Name "name of controller" -credential $cred | out-null
$delete = Get-NaSnapshot -Name $vol
if ($delete -ne $null){
foreach($snap in $delete){
Write-Output $volname $snap.Name
Remove-NaSnapshot -Volume $vol -SnapName $snap.Name -Confirm:$false}}}

--executing function (you can get case-sensitive volume names by checking DATA Ontap Management Tool->FilerView)

nas volume1

nas volume 2

nas volume 3


Check out the KB!
Knowledge Base
All Community Forums