You can make a custom PowerShell script to take an Azure Snapshot with Retention period, mount a network drive to delete a specific VM folder, and keep track every step to record the error then send a summary email report daily.
This post will guide you the detailed PowerShell command.
The custom script includes the steps for the whole process automatically:
- Login Target Azure Tenant (Record error if happen)
- Take VM Snapshot (Record error if happen)
- Delete VM Specific File (Record error if happen)
- Housekeeping job – Snapshot Retention (Record error if happen)
- Housekeeping job – PowerShell Log Retention (Record error if happen)
- Send Summary Report by Email
Step 1 – Login Target Azure Tenant (Record error if happen)

Step 2 – Take VM Snapshot (Record error if happen)

Step 3 – Delete VM Specific File (Record error if happen)

Step 4 – Housekeeping job – Snapshot Retention (Record error if happen)

Step 5 – Housekeeping job – PowerShell Log Retention (Record error if happen)

Step 6 – Send Summary Report by Email


You can visit our SOS GitHub for downloading the source code as a template:https://github.com/SOSHKMVP/AzurePowerShell/blob/main/Take%20Snapshot%20with%20Retention/TakeSnap_With_Retention.ps1

Eric Chan
Microsoft MVP
SOS Group Limited