Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-DbaBackupHistory, better docs for Since parameter #9604

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions public/Get-DbaDbBackupHistory.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ function Get-DbaDbBackupHistory {
If this switch is enabled, a large amount of information is returned, similar to what SQL Server itself returns.

.PARAMETER Since
Specifies a starting point for the search for backups. If a DateTime object is passed, that will be used. If a TimeSpan object is passed, that will be added to Get-Date and the resulting value will be used.
Specifies a starting point for the search for backups.
This is compared to the date stored in msdb, which gets stored in the timezone of the running SQL Server instance.
If a DateTime object is passed, that will be used.
If a TimeSpan object is passed, that will be added to Get-Date and the resulting value will be used.

.PARAMETER RecoveryFork
Specifies the Recovery Fork you want backup history for.
Expand Down Expand Up @@ -100,7 +103,7 @@ function Get-DbaDbBackupHistory {
Does the same as above but connect to SqlInstance2014a as SQL user "sqladmin"

.EXAMPLE
PS C:\> Get-DbaDbBackupHistory -SqlInstance SqlInstance2014a -Database db1, db2 -Since '2016-07-01 10:47:00'
PS C:\> Get-DbaDbBackupHistory -SqlInstance SqlInstance2014a -Database db1, db2 -Since ([DateTime]'2016-07-01 10:47:00')

Returns backup information only for databases db1 and db2 on SqlInstance2014a since July 1, 2016 at 10:47 AM.

Expand Down Expand Up @@ -161,7 +164,7 @@ function Get-DbaDbBackupHistory {
[switch]$IncludeCopyOnly,
[Parameter(ParameterSetName = "NoLast")]
[switch]$Force,
[psobject]$Since = (Get-Date '01/01/1970'),
[psobject]$Since = ([DateTime]::ParseExact("1970-01-01", "yyyy-MM-dd", [System.Globalization.CultureInfo]::InvariantCulture)),
[ValidateScript( { ($_ -match '^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$') -or ('' -eq $_) })]
[string]$RecoveryFork,
[switch]$Last,
Expand Down Expand Up @@ -230,9 +233,9 @@ function Get-DbaDbBackupHistory {
return
}

if ($Since -is [timespan]) {
$Since = (Get-Date).add($Since);
} elseif ($Since -isnot [datetime]) {
if ($Since -is [TimeSpan]) {
$Since = (Get-Date).Add($Since);
} elseif ($Since -isnot [DateTime]) {
Stop-Function -Message "-Since must be either a DateTime or TimeSpan object."
return
}
Expand Down