Skip to content

Commit 79d7a99

Browse files
authored
Merge pull request #107711 from MadhaviKashyap/patch-1
Powershell command to delete multiple snapshots
2 parents 555563e + 5069605 commit 79d7a99

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

articles/storage/files/storage-snapshots-files.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,26 @@ Before you deploy the share snapshot scheduler, carefully consider your share sn
9393

9494
Share snapshots provide only file-level protection. Share snapshots don't prevent fat-finger deletions on a file share or storage account. To help protect a storage account from accidental deletions, you can either [enable soft delete](storage-files-prevent-file-share-deletion.md), or lock the storage account and/or the resource group.
9595

96+
## Delete multiple snapshots
97+
98+
Use the following PowerShell script to delete multiple file share snapshots. Be sure to replace **storageaccount_name**, **resource-GROUP**, and **sharename** with your own values.
99+
100+
```powerShell
101+
$storageAccount = "storageaccount_name" 
102+
$RG = "resource-GROUP" $sharename = "sharename"
103+
$sa = get-azstorageaccount -Name $storageAccount -ResourceGroupName $RG $items = "","","" 
104+
ForEach ($item in $items)
105+
{
106+
    $snapshotTime = "$item"
107+
    $snap = Get-AzStorageShare -Name $sharename -SnapshotTime "$snapshotTime" -Context $sa.Context
108+
    $lease = [Azure.Storage.Files.Shares.Specialized.ShareLeaseClient]::new($snap.ShareClient)
109+
    $l
110+
}
111+
```
96112
## Next steps
97113
- Working with share snapshots in:
98114
- [Azure file share backup](../../backup/azure-file-share-backup-overview.md)
99115
- [Azure PowerShell](/powershell/module/az.storage/new-azrmstorageshare)
100116
- [Azure CLI](/cli/azure/storage/share#az-storage-share-snapshot)
101117
- [Windows](storage-how-to-use-files-windows.md#accessing-share-snapshots-from-windows)
102-
- [Share snapshot FAQ](storage-files-faq.md#share-snapshots)
118+
- [Share snapshot FAQ](storage-files-faq.md#share-snapshots)

0 commit comments

Comments
 (0)