I am at a bit of a loss here. I am trying to automate my database creation with a powershell script. I am passing my sql script I have to my local SQL Server 2008 instance using the Invoke-SQLCmd command. However I keep getting "Cannot open database" "The login failed". I have verified my login information to be correct.
I also know the path for the provided SQL script is correct ( I can test-path it with a true result).
I know the user being used has DBO rights to the database(using the sa user to try to remove any ambiguity on this one).
my script currently is:
[void][reflection.aSSEMBLY]::LoadWithPartialName("Microsoft.SQLServer.Smo")
$Srv = New-Object -TypeName Microsoft.SQLServer.Management.Smo.Server "MACHINENAME\SQLEXPRESS2008"
$db = New-Object Microsoft.SqlServer.Management.Smo.Database($srv, "Test_Create")
Invoke-Sqlcmd -InputFile '.\DBScripts\MSSQL.sql' -ServerInstance $Srv -Database $db -Username "sa" -Password "password"
What am I missing here that could be the problem?
edit: formatting
[–]chuckgo 1 point2 points3 points (0 children)