MSSql DB On Windows Pattern execute sqlcmd

ClydeW
Tera Contributor

Getting connection error trying to execute the following sqlcmd:

Have created NT account credentials and able to discover the host server, but step to parse command output for below sqlcmd command getting connection error.

"sqlcmd -h-1 -s, -E -S tcp:" + $computer_system.primaryHostname + "\" + $instance_name + "," + $tcp_port + " -Q \"SELECT name , compatibility_level, create_date, collation_name, state_desc, recovery_model FROM sys.databases;\""

 

Horizontal log entry:

Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: No connection could be made because the target machine actively refused it.

.

Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login failed for user '???\accountId'..

Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online

 

Any suggestions on how to resolve this would be great.

 

Thanks

Clyde

 

 

1 REPLY 1

Rutuja7987
Tera Contributor

Hi @ClydeW 

 

Are you able to resolve error?

How did you execute query via sqlcmd cmdlet??

 I have requirement to discover collation_name, I am not able to achieve this

 

Thank you!