Posted in
Windows Powershell |
1 Comment | 5,092 views | 11/05/2016 15:42
You can get detailed info about SQL Server Availability Group Listeners via following code:
1
2
3
4
5
6
7
8
9
10
| $MSSQLServerManager = New-Object 'Microsoft.SqlServer.Management.SMO.Server'
# Get SQL Availability Group Listener
$HostSQLAvailabilityGroupListener = @($MSSQLServerManager.AvailabilityGroupListeners)[0]
# Get SQL Availability Group Listener Properties
$HostSQLName = $HostSQLAvailabilityGroupListener.Name;
$HostSQLAvailabilityGroupListenerGuid = $HostSQLAvailabilityGroupListener.UniqueId;
$HostSQLIPAddresses = $HostSQLAvailabilityGroupListener.AvailabilityGroupListenerIPAddresses;
$HostSQLPortNumber = $HostSQLAvailabilityGroupListener.PortNumber; |
$MSSQLServerManager = New-Object 'Microsoft.SqlServer.Management.SMO.Server'
# Get SQL Availability Group Listener
$HostSQLAvailabilityGroupListener = @($MSSQLServerManager.AvailabilityGroupListeners)[0]
# Get SQL Availability Group Listener Properties
$HostSQLName = $HostSQLAvailabilityGroupListener.Name;
$HostSQLAvailabilityGroupListenerGuid = $HostSQLAvailabilityGroupListener.UniqueId;
$HostSQLIPAddresses = $HostSQLAvailabilityGroupListener.AvailabilityGroupListenerIPAddresses;
$HostSQLPortNumber = $HostSQLAvailabilityGroupListener.PortNumber;
You can also check other properties by listing all properties of $HostSQLAvailabilityGroupListener.