I am trying to create a empty database in SQL server using powershell and SMO but cannot seem to find a way of doing it. Is this possible?
Connection script for sql
Far too much hassle above if you ask me, this works just fine:
$s = New-PSSession -ComputerName SQLDB -Credential DOMAIN\USER
Invoke-Command -Session $s -ScriptBlock {Invoke-Sqlcmd -ServerInstance SQLDB\INSTANCE -InputFile C:\Users\USER\Downloads\CREATEDB.sql}
Only thing is - you will need to have your DB script already formed and called from thus said location. This is easier for me though due to this being a small part of a bigger script - i dont want to bloat my script if i dont have to and can call SQL scripts from a repo.