Skip to content

Commit c83b09c

Browse files
Powershell command to delete multiple snapshots
Worked on a case and helped customer to fix this issue . The proposed solution is tested and successful.
1 parent 5d5ab8f commit c83b09c

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,23 @@ 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+
**Powershell command to delete multiple snapshots.**
97+
```powerShell
98+
$storageAccount = "storageaccount_name" 
99+
$RG = "resource-GROUP" $sharename = "sharename"
100+
$sa = get-azstorageaccount -Name $storageAccount -ResourceGroupName $RG $items = "","","" 
101+
ForEach ($item in $items)
102+
{
103+
    $snapshotTime = "$item"
104+
    $snap = Get-AzStorageShare -Name $sharename -SnapshotTime "$snapshotTime" -Context $sa.Context
105+
    $lease = [Azure.Storage.Files.Shares.Specialized.ShareLeaseClient]::new($snap.ShareClient)
106+
    $l
107+
}
108+
```
96109
## Next steps
97110
- Working with share snapshots in:
98111
- [Azure file share backup](../../backup/azure-file-share-backup-overview.md)
99112
- [Azure PowerShell](/powershell/module/az.storage/new-azrmstorageshare)
100113
- [Azure CLI](/cli/azure/storage/share#az-storage-share-snapshot)
101114
- [Windows](storage-how-to-use-files-windows.md#accessing-share-snapshots-from-windows)
102-
- [Share snapshot FAQ](storage-files-faq.md#share-snapshots)
115+
- [Share snapshot FAQ](storage-files-faq.md#share-snapshots)

0 commit comments

Comments
 (0)