Avatar of deanlee17

asked on 

PowerShell code error

Hi All,

Can anyone spot the problem with this....
function global:RestoreDB 
    [string] $dbCommand = "RESTORE DATABASE [MS] " +
    "FROM  DISK = 'C:\dean\northwind.bak' " +
    "MOVE 'Northwind' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\MS.MDF', " +
    "MOVE 'Northwind_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\MS_1.ldf'," +
    "NOUNLOAD,  STATS = 10"
    OSQL.EXE -E -Q $dbCommand

Open in new window

Error Message:

PS C:\Windows\system32> RestoreDB
Msg 102, Level 15, State 1, Server Main007, Line 1
Incorrect syntax near 'MOVE'.

Many Thanks,
PowershellMicrosoft SQL Server

Avatar of undefined
Last Comment
Bob McCoy

8/22/2022 - Mon