Invoke-SqlRestore

Performs a SQL database or log restore.

Syntax

Invoke-SqlRestore [-sqlserver] <Object> [-dbname] <String> [-filepath] <String> [[-action] {Database | Files | OnlinePage | OnlineFiles | Log}] [[-stopat] <String>] [[-relocatefiles] <Hashtable>] [[-force]] [[-norecovery]] [[-keepreplication]] [<CommonParameters>]

Detailed Description

The Invoke-SqlRestore function performs a SQL database or log restore of the specified database.

Related Commands

* Invoke-SqlRestore

Parameters

Name Description Required? Pipeline Input Default Value
sqlserver    true  false   
dbname    true  false   
filepath    true  false   
action    false  false   
stopat    false  false   
relocatefiles    false  false   
force    false  false   
norecovery    false  false   
keepreplication    false  false   

Input Type

None You cannot pipe objects to Invoke-SqlRestore

Return Values

None This function does not generate any output.

Examples

EXAMPLE 1

Invoke-SqlRestore "Z002\sql2k8" "pubs"  "C:\sqlrec\pubs.bak" -force
This command restores the pubs database from disk replacing the existing database if exists.

EXAMPLE 2

Invoke-SqlRestore "Z002\sql2k8" "NorthwindTestRestore"  "C:\sqlrec\Northwind.bak" -relocatefiles @{Northwind='C:\Program Files\Microsoft SQL Server\MSSQL10.SQL2K8\MSSQL\DATA\northwnd2.mdf'; Northwind_log='C:\Program Files\Microsoft SQL Server\MSSQL10.SQL2K8\MSSQL\DATA\northwnd2.ldf'} -force
This command restores the Northwind database as NorthwindTestRestore, relocates database files by passing a hashtable of file names and replaces the existing database if exists.