---
title: "Remove-DbaDbSnapshot"
description: "Drops database snapshots from SQL Server instances"
url: "https://dbatools.io/Remove-DbaDbSnapshot/"
availability: "Windows, Linux, macOS"
tags: ["Snapshot", "Database"]
author: "Simone Bizzotto (@niphold)"
source: "https://github.com/dataplat/dbatools/blob/master/public/Remove-DbaDbSnapshot.ps1"
last_updated: "2024-01-01"
---

# Remove-DbaDbSnapshot

## Synopsis

Drops database snapshots from SQL Server instances

## Description

Removes database snapshots by executing DROP DATABASE statements against the target SQL Server instances. Database snapshots are point-in-time, read-only copies of databases that consume minimal space through copy-on-write technology. This function helps DBAs clean up obsolete snapshots that are no longer needed for reporting, testing, or recovery purposes. The Force parameter can terminate active connections to snapshots that might otherwise prevent the drop operation from succeeding.

## Syntax

```powershell
Remove-DbaDbSnapshot
    [[-SqlInstance] <DbaInstanceParameter[]>]
    [[-SqlCredential] <PSCredential>]
    [[-Database] <String[]>]
    [[-ExcludeDatabase] <String[]>]
    [[-Snapshot] <String[]>]
    [[-InputObject] <Database[]>]
    [-AllSnapshots]
    [-Force]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

```

## Examples

### Example 1: Removes database snapshots named HR_snap_20161201 and HR_snap_20161101

```powershell
PS C:\> Remove-DbaDbSnapshot -SqlInstance sql2014 -Snapshot HR_snap_20161201, HR_snap_20161101
```

### Example 2: Removes all database snapshots having HR and Accounting as base dbs

```powershell
PS C:\> Remove-DbaDbSnapshot -SqlInstance sql2014 -Database HR, Accounting
```

### Example 3: Removes all database snapshots having HR and Accounting as base dbs

```powershell
PS C:\> Get-DbaDbSnapshot -SqlInstance sql2014 -Database HR, Accounting | Remove-DbaDbSnapshot
```

### Example 4: Removes HR_snapshot and Accounting_snapshot

```powershell
PS C:\> Remove-DbaDbSnapshot -SqlInstance sql2014 -Snapshot HR_snapshot, Accounting_snapshot
```

### Example 5: Removes all snapshots associated with databases that have dumpsterfire in the name

```powershell
PS C:\> Get-DbaDbSnapshot -SqlInstance sql2016 | Where-Object SnapshotOf -like '*dumpsterfire*' | Remove-DbaDbSnapshot
```

### Example 6: Allows the selection of snapshots on sql2016 to remove

```powershell
PS C:\> Get-DbaDbSnapshot -SqlInstance sql2016 | Out-GridView -PassThru | Remove-DbaDbSnapshot
```

### Example 7: Removes all database snapshots from sql2014

```powershell
PS C:\> Remove-DbaDbSnapshot -SqlInstance sql2014 -AllSnapshots
```

### Example 8: Removes all database snapshots from sql2014 and prompts for each database

```powershell
PS C:\> Remove-DbaDbSnapshot -SqlInstance sql2014 -AllSnapshots -Confirm
```

### Optional Parameters

##### -SqlInstance

The target SQL Server instance or instances

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value |  |

##### -SqlCredential

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).  
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported.  
For MFA support, please use Connect-DbaInstance.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value |  |

##### -Database

Specifies the base database(s) whose snapshots should be removed. Only snapshots created from these source databases will be dropped.  
Use this when you need to clean up snapshots for specific databases while leaving other snapshots intact.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value |  |

##### -ExcludeDatabase

Excludes snapshots from the specified base database(s) from removal. All other snapshots on the instance will be removed.  
Use this when you want to remove most snapshots but preserve those from critical databases.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value |  |

##### -Snapshot

Specifies the exact snapshot name(s) to remove. Accepts multiple snapshot names for targeted removal operations.  
Use this when you know the specific snapshot names you want to drop, such as outdated test or reporting snapshots.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value |  |

##### -InputObject

Accepts database snapshot objects from Get-DbaDbSnapshot for pipeline operations. This allows filtering and processing snapshots before removal.  
Use this for complex filtering scenarios where you first identify specific snapshots with Get-DbaDbSnapshot.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | true (ByValue) |
| Default Value |  |

##### -AllSnapshots

Removes all database snapshots found on the target SQL Server instance(s). This affects every snapshot regardless of source database.  
Use this for complete snapshot cleanup operations, typically during maintenance windows or server decommissioning.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value | False |

##### -Force

Terminates active connections and running queries against snapshots to allow the drop operation to complete successfully.  
Use this when snapshots have active sessions that would normally block the removal process.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value | False |

##### -EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.  
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.  
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value | False |

##### -WhatIf

Shows what would happen if the command were to run

| Property | Value |
| --- | --- |
| Alias | wi |
| Required | False |
| Pipeline | false |
| Default Value |  |

##### -Confirm

Prompts for confirmation of every step.

| Property | Value |
| --- | --- |
| Alias | cf |
| Required | False |
| Pipeline | false |
| Default Value |  |

## Outputs

**PSCustomObject**

**Returns one object per snapshot dropped, with the following properties:**

**Default display properties (via Select-DefaultView):**

- ComputerName: The name of the computer where the snapshot was dropped
- InstanceName: The SQL Server instance name
- SqlInstance: The full SQL Server instance name (computer\instance)
- Name: The name of the snapshot that was dropped (displayed as Name, stored as Database)
- Status: The result of the drop operation (either "Dropped" on success or the error message on failure)

---

Part of [dbatools](https://dbatools.io/), a free and open source PowerShell module for SQL Server administration. Full command index: https://dbatools.io/commands/
