ServerConnection.TrueName Property

Gets the name of the server.

Namespace:  Microsoft.SqlServer.Management.Common
Assembly:  Microsoft.SqlServer.ConnectionInfo (in Microsoft.SqlServer.ConnectionInfo.dll)

public string TrueName { get; set; }

Property Value

Type: System.String
A String value that specifies the name of the server.

The name of the server is the equivalent to the value returned by the @@SERVERNAME Transact-SQL function.

C#

ServerConnection conn = new ServerConnection();
Console.WriteLine(conn.TrueName);

PowerShell

$conn = new-object Microsoft.SqlServer.Management.Common.ServerConnection
Write-Host $conn.TrueName

Community Additions

ADD
Show: