Restore-DbaDatabase,dbatools
![Image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyuB7bIp-A3af9hREbB8WaOT9d9fmmeRwIkLnBNFr2bIVD51nTT3UTMZp1uLWj7OLVrmaCG-qQ8L792iikptbJe05bId-WTPx5MEektyV-_9aaKmvEjbBB6T_l5IYroTIYB1rHayrE-_splUgi6-0JQytHluCpE7BcbZW0-aZqXDtlQSzcOYVicKDJ8Q-h/s16000/Image1.png)
We can use below dbatools to restore database. Export-DbaUser will export all the respective database users to a spcific file. If you want all the user script need to add single file then user -FilePath parameter.If you want indivual files need to created user -Path parameter. cls Export - DbaUser ` - SqlInstance InstanceNameHere ` - Database DatabaseNameHere ` - FilePath C : \ Temp \ Users_DatbaseNameHere_InstanceNameHere. sql ` - Verbose In the below command -Path parameter you no need pass .BAK file it will automatically read file. -WithReplace option will overwrite the existing database. Restore - DbaDatabase ` - SqlInstance InstanceNameHere ` - DatabaseName DatabaseNameHere ` - Path H: \ TodayRestore ` - DestinationDataDirectory "F:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Data\DatabaseName_Data.mdf" ` - DestinationLogDirectory "G:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Data\DatbaseName_Log.ldf" ` - Wit...