Hello there,
Try the command below, the sample delete snapshots older then 10 days.
rg = 'snapshots'
$snapshotnames = (Get-AzureRmSnapshot -ResourceGroupName $rg).name
foreach($snapname in $snapshotnames)
{
Get-AzureRmSnapshot -ResourceGroupName $rg -SnapshotName $snapname | ?{($_.TimeCreated) -lt ([datetime]::UtcNow.AddDays(-10))} | remove-azurermsnapshot -force
}
Hope this resolves your Query !!
--If the reply is helpful, please Upvote and Accept it as an answer--
SSRS How to delete history snapshots older than X days programmatically?
We have a lot of SSRS reports creating a lot of history snapshots. We want to delete all snapshots for a report older than X days. Each report can have a different history retention policy, one might be to keep 30 days, one might be to keep 2 years. We'll handle this by putting this information in a sql server table and use that when we delete history snapshots.
On SwaggerHub I found a Delete HistorySnapshots, but it appears it's deleting ALL history snapshots, which we don't want. I can't find anything with ReportingServicesTools for deleting history snapshots.
One thought we had was to do the same thing that happens when you delete a history snapshot through the web interface. When you do this, what is really happening?
Is it running the only stored procedure DeleteHistoryRecord, or doing some other things too?
We know we can do it via SQL, but we're not sure of all the tables involved and don't want to leave any data behind, or mess things up.
Any thoughts or suggestions on the best way to do this?
Thanks!
1 answer
Sort by: Most helpful
-
Limitless Technology 44,121 Reputation points
2023-09-01T08:12:27.0266667+00:00