Skip to content

Commit 8e3f299

Browse files
authored
Get-DbaBackupHistory, better docs for Since parameter (#9604)
1 parent 8018b44 commit 8e3f299

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

public/Get-DbaDbBackupHistory.ps1

+9-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ function Get-DbaDbBackupHistory {
3131
If this switch is enabled, a large amount of information is returned, similar to what SQL Server itself returns.
3232
3333
.PARAMETER Since
34-
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.
34+
Specifies a starting point for the search for backups.
35+
This is compared to the date stored in msdb, which gets stored in the timezone of the running SQL Server instance.
36+
If a DateTime object is passed, that will be used.
37+
If a TimeSpan object is passed, that will be added to Get-Date and the resulting value will be used.
3538
3639
.PARAMETER RecoveryFork
3740
Specifies the Recovery Fork you want backup history for.
@@ -100,7 +103,7 @@ function Get-DbaDbBackupHistory {
100103
Does the same as above but connect to SqlInstance2014a as SQL user "sqladmin"
101104
102105
.EXAMPLE
103-
PS C:\> Get-DbaDbBackupHistory -SqlInstance SqlInstance2014a -Database db1, db2 -Since '2016-07-01 10:47:00'
106+
PS C:\> Get-DbaDbBackupHistory -SqlInstance SqlInstance2014a -Database db1, db2 -Since ([DateTime]'2016-07-01 10:47:00')
104107
105108
Returns backup information only for databases db1 and db2 on SqlInstance2014a since July 1, 2016 at 10:47 AM.
106109
@@ -161,7 +164,7 @@ function Get-DbaDbBackupHistory {
161164
[switch]$IncludeCopyOnly,
162165
[Parameter(ParameterSetName = "NoLast")]
163166
[switch]$Force,
164-
[psobject]$Since = (Get-Date '01/01/1970'),
167+
[psobject]$Since = ([DateTime]::ParseExact("1970-01-01", "yyyy-MM-dd", [System.Globalization.CultureInfo]::InvariantCulture)),
165168
[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 $_) })]
166169
[string]$RecoveryFork,
167170
[switch]$Last,
@@ -230,9 +233,9 @@ function Get-DbaDbBackupHistory {
230233
return
231234
}
232235

233-
if ($Since -is [timespan]) {
234-
$Since = (Get-Date).add($Since);
235-
} elseif ($Since -isnot [datetime]) {
236+
if ($Since -is [TimeSpan]) {
237+
$Since = (Get-Date).Add($Since);
238+
} elseif ($Since -isnot [DateTime]) {
236239
Stop-Function -Message "-Since must be either a DateTime or TimeSpan object."
237240
return
238241
}

0 commit comments

Comments
 (0)