How to get the SQL Server version details (CU) install in sql server VM from cloud shell?

Ummer, Fazil 0 Reputation points
2024-05-02T10:58:37.3566667+00:00

Hi,

What are the options available to get SQL server versions(CU) install in SQL Server VM. THis is needed to maintain the wiki package for multiple vm across the multiple environment, I have tried

$serverName = "YourSqlServerName"

$databaseName = "master"

$query = "SELECT SERVERPROPERTY('ProductVersion') AS 'ProductVersion', SERVERPROPERTY('ProductLevel') AS 'ProductLevel'"

$username = "YourUsername"

$password = "YourPassword"

Invoke-Sqlcmd -ServerInstance $serverName -Database $databaseName -Query $query -Username $username -Password $password

but resulted in " A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 40 - Could not open a connection to SQL Server)".

Thanks

Fazil Ummer

SQL Server on Azure Virtual Machines
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,578 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Olaf Helper 45,016 Reputation points
    2024-05-02T11:11:37.51+00:00

    The server was not found or was not accessible

    As the error message says.

    Can you connect to the SQL Server using SSMS with same server name and credentials?


  2. ShaktiSingh-MSFT 15,336 Reputation points
    2024-05-03T08:35:32.74+00:00

    Hi Ummer, Fazil •,

    Thanks for the reply.

    Since from Azure Portal Cloudshell you are trying and Network configuration is correct, please double-check the credentials used and you have needed permissions.

    If all above works fine and still you are facing issue, I would request you to raise support case so that a dedicated engineer can deeply investigate the issue.

    Let us know if you need help in raising the same. Thanks.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.