dbatools is a free PowerShell module with over 180 SQL Server administration, best practice and migration commands included.


Remove-DbaDatabaseSnapshot

Removes (drops) database snapshots from the server

Screenshots

Examples

To remove all database snapshots from sqlserver2014a

Remove-DbaDatabaseSnapshot -SqlServer sqlserver2014a -AllSnapshots

To remove database snapshots named HR_snap_20161201 and HR_snap_20161101

Remove-DbaDatabaseSnapshot -SqlServer sqlserver2014a -Snapshots HR_snap_20161201, HR_snap_20161101

To remove all database snapshots having HR and Accounting as base dbs

Remove-DbaDatabaseSnapshot -SqlServer sqlserver2014a -Databases HR, Accounting

To remove HR_snapshot and Accounting_snapshot

Remove-DbaDatabaseSnapshot -SqlServer sqlserver2014a -Snapshots HR_snapshot, Accounting_snapshot

To remove all snapshots associated with databases that have dumpsterfire in the name

Get-DbaDatabaseSnapshot -SqlServer sql2016 | Where SnapshotOf -like ‘*dumpsterfire*’ | Remove-DbaDatabaseSnapshot

Author

This command was created by Simone Bizzotto. You can find Simone on LinkedIn.

Get-Help

From PowerShell, execute Get-Help Remove-DbaDatabaseSnapshot -Detailed for more information on this function.

Source Code

Want to see the source code? View Remove-DbaDatabaseSnapshot.ps1 on GitHub
 

Related commands