How to login with SQL Authentication using PowerShell

Have a look here: http://msdn.microsoft.com/en-us/library/cc281947.aspx.

Your issue is dealt with in the section "Managing SQL Server Authentication Connections".


You can also do a one-off using the Invoke-Sqlcmd statement. You have to have the SQL 2008 Powershell host installed for this (sqlps.exe) which gets installed with SQL 2008.

PS C:\> sqlps
PS>invoke-sqlcmd -query "SELECT * FROM sys.databases" -serverinstance "foo" -username "homer" -password "simpsonsrock"