I have sqlcmd.exe
from both SQLServer 2008 and SQLServer 2012:
PS C:\\> Get-Command sqlcmd.exe
Definition
----------
C:\\Program Files\\Microsof
I have been doing this at work recently and had some initial troubles connecting to a local Database. To get it to work, I ran the following code;
C:\> Import-Module sqlps -DisableNameChecking
SQLSERVER\:> cd ".\SQL\$(hostname)"
SQLSERVER\:> Invoke-Sqlcmd -Username "user" -Password "pass" -Database "databasename" -Query "foobar"
This worked for me and I was able to query the database. Obviously, change the Username, Password and Database parameter details to whatever the name of your database on the SQL Instance is called.