< Back
Remove-DbaDbSnapshot
Post
NAME Remove-DbaDbSnapshot
SYNOPSIS
Removes database snapshots
SYNTAX
Remove-DbaDbSnapshot [[-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]
[[-SqlCredential] <Pscredential>] [[-Database] <System.String[]>] [[-ExcludeDatabase] <System.String[]>]
[[-Snapshot] <System.String[]>] [[-InputObject] <Microsoft.SqlServer.Management.Smo.Database[]>] [-AllSnapshots
<Switch>] [-Force <Switch>] [-EnableException <Switch>] [<CommonParameters>]
DESCRIPTION
Removes (drops) database snapshots from the server
PARAMETERS
-AllSnapshots [<Switch>]
Specifies that you want to remove all snapshots from the server
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Database [<System.String[]>]
Removes snapshots for only this specific base db
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-EnableException [<Switch>]
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.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-ExcludeDatabase [<System.String[]>]
Removes snapshots excluding this specific base dbs
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Force [<Switch>]
Will forcibly kill all running queries that prevent the drop process.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-InputObject [<Microsoft.SqlServer.Management.Smo.Database[]>]
Enables input from Get-DbaDbSnapshot
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Snapshot [<System.String[]>]
Restores databases from snapshot with this name only
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlCredential [<Pscredential>]
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.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlInstance [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]
The target SQL Server instance or instances
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
Tags: Snapshot, Database
Author: Simone Bizzotto (@niphold)
Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Remove-DbaDbSnapshot -SqlInstance sql2014 -Snapshot HR_snap_20161201, HR_snap_20161101
Removes database snapshots named HR_snap_20161201 and HR_snap_20161101
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Remove-DbaDbSnapshot -SqlInstance sql2014 -Database HR, Accounting
Removes all database snapshots having HR and Accounting as base dbs
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Get-DbaDbSnapshot -SqlInstance sql2014 -Database HR, Accounting | Remove-DbaDbSnapshot
Removes all database snapshots having HR and Accounting as base dbs
-------------------------- EXAMPLE 4 --------------------------
PS C:\\>Remove-DbaDbSnapshot -SqlInstance sql2014 -Snapshot HR_snapshot, Accounting_snapshot
Removes HR_snapshot and Accounting_snapshot
-------------------------- EXAMPLE 5 --------------------------
PS C:\\>Get-DbaDbSnapshot -SqlInstance sql2016 | Where-Object SnapshotOf -like '*dumpsterfire*' |
Remove-DbaDbSnapshot
Removes all snapshots associated with databases that have dumpsterfire in the name
-------------------------- EXAMPLE 6 --------------------------
PS C:\\>Get-DbaDbSnapshot -SqlInstance sql2016 | Out-GridView -Passthru | Remove-DbaDbSnapshot
Allows the selection of snapshots on sql2016 to remove
-------------------------- EXAMPLE 7 --------------------------
PS C:\\>Remove-DbaDbSnapshot -SqlInstance sql2014 -AllSnapshots
Removes all database snapshots from sql2014
-------------------------- EXAMPLE 8 --------------------------
PS C:\\>Remove-DbaDbSnapshot -SqlInstance sql2014 -AllSnapshots -Confirm
Removes all database snapshots from sql2014 and prompts for each database
RELATED LINKS
https://dbatools.io/Remove-DbaDbSnapshot
SYNOPSIS
Removes database snapshots
SYNTAX
Remove-DbaDbSnapshot [[-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]
[[-SqlCredential] <Pscredential>] [[-Database] <System.String[]>] [[-ExcludeDatabase] <System.String[]>]
[[-Snapshot] <System.String[]>] [[-InputObject] <Microsoft.SqlServer.Management.Smo.Database[]>] [-AllSnapshots
<Switch>] [-Force <Switch>] [-EnableException <Switch>] [<CommonParameters>]
DESCRIPTION
Removes (drops) database snapshots from the server
PARAMETERS
-AllSnapshots [<Switch>]
Specifies that you want to remove all snapshots from the server
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Database [<System.String[]>]
Removes snapshots for only this specific base db
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-EnableException [<Switch>]
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.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-ExcludeDatabase [<System.String[]>]
Removes snapshots excluding this specific base dbs
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Force [<Switch>]
Will forcibly kill all running queries that prevent the drop process.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-InputObject [<Microsoft.SqlServer.Management.Smo.Database[]>]
Enables input from Get-DbaDbSnapshot
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Snapshot [<System.String[]>]
Restores databases from snapshot with this name only
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlCredential [<Pscredential>]
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.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlInstance [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]
The target SQL Server instance or instances
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
Tags: Snapshot, Database
Author: Simone Bizzotto (@niphold)
Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Remove-DbaDbSnapshot -SqlInstance sql2014 -Snapshot HR_snap_20161201, HR_snap_20161101
Removes database snapshots named HR_snap_20161201 and HR_snap_20161101
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Remove-DbaDbSnapshot -SqlInstance sql2014 -Database HR, Accounting
Removes all database snapshots having HR and Accounting as base dbs
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Get-DbaDbSnapshot -SqlInstance sql2014 -Database HR, Accounting | Remove-DbaDbSnapshot
Removes all database snapshots having HR and Accounting as base dbs
-------------------------- EXAMPLE 4 --------------------------
PS C:\\>Remove-DbaDbSnapshot -SqlInstance sql2014 -Snapshot HR_snapshot, Accounting_snapshot
Removes HR_snapshot and Accounting_snapshot
-------------------------- EXAMPLE 5 --------------------------
PS C:\\>Get-DbaDbSnapshot -SqlInstance sql2016 | Where-Object SnapshotOf -like '*dumpsterfire*' |
Remove-DbaDbSnapshot
Removes all snapshots associated with databases that have dumpsterfire in the name
-------------------------- EXAMPLE 6 --------------------------
PS C:\\>Get-DbaDbSnapshot -SqlInstance sql2016 | Out-GridView -Passthru | Remove-DbaDbSnapshot
Allows the selection of snapshots on sql2016 to remove
-------------------------- EXAMPLE 7 --------------------------
PS C:\\>Remove-DbaDbSnapshot -SqlInstance sql2014 -AllSnapshots
Removes all database snapshots from sql2014
-------------------------- EXAMPLE 8 --------------------------
PS C:\\>Remove-DbaDbSnapshot -SqlInstance sql2014 -AllSnapshots -Confirm
Removes all database snapshots from sql2014 and prompts for each database
RELATED LINKS
https://dbatools.io/Remove-DbaDbSnapshot