Azure PowerShell: How to delete azure file share snapshot automatically

At present we are taking azure file share snapshot daily at 12.00 PM every night. We are using the below script to take the snapshot automatically using powershell:

$context = New-AzStorageContext -StorageAccountName jgifileshare -StorageAccountKey xxxxx

$share = Get-AzStorageShare -Context $context -Name filesharename

$snapshot = $share.Snapshot()

Above script works like a charm but I am not sure How I can modify the script to check the old snapshot and delete it automatically after creating the new snapshot. Basically what I am trying to setup is I want to set a snapshot retention policy. Now I have been thinking to delete the snapshot older than 30 days.


Hey there!
Hope the solution in this link helps