sql server - Powershell Invoke-SqlCmd: Specify port -
i want connect database execute script on database, however, can access database in question specific port number.
i have along these lines in terms of code:
invoke-sqlcmd -serverinstance "servername,53806" -database "databasename" -inputfile $file.fullname -verbose | out-file -filepath "d:\test\testsqlcmd.rpt"
when run ps snippet, nothing happens @ all. nothing written report. nothing written console either. when change snippet around to:
invoke-sqlcmd -serverinstance "servername","53806" -database "databasename" -inputfile $file.fullname -verbose | out-file -filepath "d:\test\testsqlcmd.rpt"
or
invoke-sqlcmd -serverinstance servername,53806 -database "databasename" -inputfile $file.fullname -verbose | out-file -filepath "d:\test\testsqlcmd.rpt"
i errors saying value cannot null parameter serverinstance.
if remove port, scripts takes bit longer run, resulting in obvious 'a network related or instance specific error occurred while establishing connection' error notification.
how should specifiy port when using invoke-sqlcmd in serverinstance parameter.
your first syntax correct, e.g. following works me:
invoke-sqlcmd -serverinstance "dbserver,29487" -database "master" -verbose -query "select @@servername"
however make sure have configured tcp connectivity. if named instance working may you're going across named pipes connection.
an easy way test use telnet:
telnet server port
and see if connects. if doesn't that's need focus attention.
(telnet may need installed feature if it's not found).
Comments
Post a Comment