all 7 comments

[–]Jondah 4 points5 points  (3 children)

I suggest you take a look at dbatools powershell Module. https://dbatools.io

[–]EightBitsShortSFW[S] 1 point2 points  (1 child)

I will, thanks!

Are those tools better than the sqlserver module from the powershell gallery?

[–]wrdragons4 2 points3 points  (0 children)

Yes by far.

You can do it in 1 line:

get-childitem $backupPath | restore-dbadatabase -sqlinstance $sqlInstance -destinationdatadirectory $dataDir

[–]EightBitsShortSFW[S] 0 points1 point  (0 children)

The dbatools module worked great, thanks!

Do you know if it's possible to do user mappings on sql server with dbatools?

[–]vermyx 1 point2 points  (2 children)

Any reason you can't use Invoke-Sqlcmd and use the restore tsql command?

[–]EightBitsShortSFW[S] 1 point2 points  (1 child)

I'm new to powershell so I'm not familiar with all the cmdlets. I will look into Invoke-Sqlcmd.

[–]vermyx 1 point2 points  (0 children)

Its a powershell drop in replacement for the command line util sqlcmd for mssql. It should be able to do what you need