Get-SqlBackupHistory

Gets backup information about databases and returns SMO BackupSet objects for each Backup record found based on the parameters specified to this cmdlet.

语法

ByPath (默认值)

Get-SqlBackupHistory
    [[-Path] <String[]>]
    [-Since <SinceType>]
    [-StartTime <DateTime>]
    [-EndTime <DateTime>]
    [-BackupType <BackupSetType>]
    [-IncludeSnapshotBackups]
    [-TimeSpan <TimeSpan>]
    [-IgnoreProviderContext]
    [-SuppressProviderContextWarning]
    [-AccessToken <PSObject>]
    [-TrustServerCertificate]
    [-HostNameInCertificate <String>]
    [-Encrypt <String>]
    [-DatabaseName <System.Collections.Generic.List`1[System.String]>]
    [<CommonParameters>]

ByName

Get-SqlBackupHistory
    [[-ServerInstance] <String[]>]
    [-Since <SinceType>]
    [-StartTime <DateTime>]
    [-EndTime <DateTime>]
    [-BackupType <BackupSetType>]
    [-IncludeSnapshotBackups]
    [-TimeSpan <TimeSpan>]
    [-IgnoreProviderContext]
    [-SuppressProviderContextWarning]
    [-Credential <PSCredential>]
    [-ConnectionTimeout <Int32>]
    [-AccessToken <PSObject>]
    [-TrustServerCertificate]
    [-HostNameInCertificate <String>]
    [-Encrypt <String>]
    [-DatabaseName <System.Collections.Generic.List`1[System.String]>]
    [<CommonParameters>]

ByObject

Get-SqlBackupHistory
    [-InputObject] <Server[]>
    [-Since <SinceType>]
    [-StartTime <DateTime>]
    [-EndTime <DateTime>]
    [-BackupType <BackupSetType>]
    [-IncludeSnapshotBackups]
    [-TimeSpan <TimeSpan>]
    [-IgnoreProviderContext]
    [-SuppressProviderContextWarning]
    [-AccessToken <PSObject>]
    [-TrustServerCertificate]
    [-HostNameInCertificate <String>]
    [-Encrypt <String>]
    [-DatabaseName <System.Collections.Generic.List`1[System.String]>]
    [<CommonParameters>]

说明

This cmdlet searches the server instance and gets the backup records as SMO BackupSet objects for all the records found matching the specified parameters.

示例

Example 1

PS C:\> Get-SqlBackupHistory -ServerInstance test-server -DatabaseName AdventureWorks2014

Name                                     Type               Backup Start Date         Backup Finish Date
----                                     ----               -----------------         ------------------
AdventureWorks2014-Full Database Backup  Database           2/21/2017 7:52:39 PM      2/21/2017 7:52:40 PM
AdventureWorks2014-Full Database Backup  Database           3/20/2017 2:41:39 PM      3/20/2017 2:41:39 PM
AdventureWorks2014-Full-2017-07-24T22:22 Database           7/24/2017 3:23:11 PM      7/24/2017 3:23:11 PM

This example gets records for all backup types for AdventureWorks2014 database on test-server SQL instance.

参数

-AccessToken

The access token used to authenticate to SQL Server, as an alternative to user/password or Windows Authentication.

This can be used, for example, to connect to SQL Azure DB and SQL Azure Managed Instance using a Service Principal or a Managed Identity.

The parameter to use can be either a string representing the token or a PSAccessToken object as returned by running Get-AzAccessToken -ResourceUrl https://database.windows.net.

This parameter is new in v22 of the module.

参数属性

类型:PSObject
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-BackupType

The type of backup to filter on. If not specified then gets all backup types. Accepted values are defined below.

参数属性

类型:BackupSetType
默认值:None
接受的值:Database, Differential, Incremental, Log, FileOrFileGroup, FileOrFileGroupDifferential
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-ConnectionTimeout

The time to wait in seconds for a connection to be established and the dynamically generated -DatabaseName parameter to be populated.

参数属性

类型:Int32
默认值:None
支持通配符:False
不显示:False

参数集

ByName
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Credential

The PSCredential object whose username and password fields are used to connect to the SQL instance.

参数属性

类型:PSCredential
默认值:None
支持通配符:False
不显示:False

参数集

ByName
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-DatabaseName

The names of the databases whose backup records are to be retrieved. This is a dynamically populated field and so provides auto-complete suggestions on database names.

参数属性

类型:

System.Collections.Generic.List`1[System.String]

默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Encrypt

The encryption type to use when connecting to SQL Server.

This value maps to the Encrypt property SqlConnectionEncryptOption on the SqlConnection object of the Microsoft.Data.SqlClient driver.

In v22 of the module, the default is Optional (for compatibility with v21). In v23+ of the module, the default value will be 'Mandatory', which may create a breaking change for existing scripts.

This parameter is new in v22 of the module.

参数属性

类型:String
默认值:None
接受的值:Mandatory, Optional, Strict
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-EndTime

The time before which all backup records to be retrieved should have completed.

参数属性

类型:DateTime
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-HostNameInCertificate

The host name to be used in validating the SQL Server TLS/SSL certificate. You must pass this parameter if your SQL Server instance is enabled for Force Encryption and you want to connect to an instance using hostname/shortname. If this parameter is omitted then passing the Fully Qualified Domain Name (FQDN) to -ServerInstance is necessary to connect to a SQL Server instance enabled for Force Encryption.

This parameter is new in v22 of the module.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-IgnoreProviderContext

Indicates that this cmdlet does not use the current context to override the values of the ServerInstance, DatabaseName parameters. If you do not specify this parameter, the cmdlet ignores the values of these parameters, if possible, in favor of the context in which you run the cmdlet.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-IncludeSnapshotBackups

This switch will make the cmdlet obtain records for snapshot backups as well. By default such backups are not retrieved.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-InputObject

Specifies SMO Server objects to get the backup records for.

参数属性

类型:

Server[]

默认值:None
支持通配符:False
不显示:False

参数集

ByObject
Position:1
必需:True
来自管道的值:True
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Path

Specifies the SQL provider path to either a server instance or a database for this cmdlet to use to obtain BackupSets for. If not specified uses the current working location.

参数属性

类型:

String[]

默认值:None
支持通配符:False
不显示:False

参数集

ByPath
Position:1
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-ServerInstance

The name of the server instances which this cmdlet will target.

参数属性

类型:

String[]

默认值:None
支持通配符:False
不显示:False

参数集

ByName
Position:1
必需:False
来自管道的值:True
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Since

Specifies an abbreviation that you can instead of the StartTime parameter.

It can be specified with the EndTime parameter.

You cannot use the StartTime parameter, if you use this parameter.

The acceptable values for this parameter are:

  • Midnight (gets all the job history information generated after midnight)
  • Yesterday (gets all the job history information generated in the last 24 hours)
  • LastWeek (gets all the job history information generated in the last week)
  • LastMonth (gets all the job history information generated in the last month)

参数属性

类型:SinceType
默认值:None
接受的值:Midnight, Yesterday, LastWeek, LastMonth
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-StartTime

Gets the backup records which started after this specified time.

参数属性

类型:DateTime
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-SuppressProviderContextWarning

Suppresses the warning when the cmdlet is using the provider context.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-TimeSpan

If specified, it causes the cmdlet to filter records generated more than 'Timespan' ago.

参数属性

类型:TimeSpan
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-TrustServerCertificate

Indicates whether the channel will be encrypted while bypassing walking the certificate chain to validate trust.

In v22 of the module, the default is $true (for compatibility with v21). In v23+ of the module, the default value will be '$false', which may create a breaking change for existing scripts.

This parameter is new in v22 of the module.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

输入

System.String

Microsoft.SqlServer.Management.Smo.Server

输出

System.Object