I am not able to pass credential or says login failed(when it is correct)
$cred = $host.ui.PromptForCredential("Need credentials for the Server", "Please enter your user name and password.", "", "NetBiosUserName")
Invoke-Sqlcmd -Credential $cred -Query (SELECT * from TESTDB" -ServerInstance "test4"
Request the expert help to get this corrected. it looks like the -credential doesnt work for invoke-sqlcmd. I see few answer as run as powershell with the required accounts, but I am combining many other script and want to work on credential popup…any help?
Not from SQL Drive, I had to install module and connecting remotely. I get the error as login failed for user <username>. It using the default Instance and therefore just the servername.