Posted in
Windows Powershell |
No Comment | 2,129 views | 25/06/2016 17:17
You can get detailed info about SQL Server Availability Replicas via following code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| $MSSQLServerManager = New-Object 'Microsoft.SqlServer.Management.SMO.Server'
# Get SQL Availability Replicas
$HostSQLAvailabilityReplica = @($MSSQLServerManager.AvailabilityReplicas)[0]
# Get SQL Availability Group Replicas Properties
$HostSQLName = $HostSQLAvailabilityReplica.Name;
$HostSQLAvailabilityReplicaGuid = $HostSQLAvailabilityReplica.UniqueId;
$HostSQLRole = $HostSQLAvailabilityReplica.Role;
$HostSQLAvailabilityMode = $HostSQLAvailabilityReplica.AvailabilityMode;
$HostSQLConnectionModeInPrimaryRole = $HostSQLAvailabilityReplica.ConnectionModeInPrimaryRole;
$HostSQLConnectionModeInSecondaryRole = $HostSQLAvailabilityReplica.ConnectionModeInSecondaryRole;
$HostSQLEndpointUrl = $HostSQLAvailabilityReplica.EndpointUrl;
$HostSQLFailoverMode = $HostSQLAvailabilityReplica.FailoverMode;
$HostSQLJoinState = $HostSQLAvailabilityReplica.JoinState;
$HostSQLQuorumVoteCount = $HostSQLAvailabilityReplica.QuorumVoteCount;
$HostSQLSessionTimeout = $HostSQLAvailabilityReplica.SessionTimeout;
$HostSQLBackupPriority = $HostSQLAvailabilityReplica.BackupPriority;
$HostSQLCreateDate = $HostSQLAvailabilityReplica.CreateDate;
$HostSQLDateLastModified = $HostSQLAvailabilityReplica.DateLastModified; |
$MSSQLServerManager = New-Object 'Microsoft.SqlServer.Management.SMO.Server'
# Get SQL Availability Replicas
$HostSQLAvailabilityReplica = @($MSSQLServerManager.AvailabilityReplicas)[0]
# Get SQL Availability Group Replicas Properties
$HostSQLName = $HostSQLAvailabilityReplica.Name;
$HostSQLAvailabilityReplicaGuid = $HostSQLAvailabilityReplica.UniqueId;
$HostSQLRole = $HostSQLAvailabilityReplica.Role;
$HostSQLAvailabilityMode = $HostSQLAvailabilityReplica.AvailabilityMode;
$HostSQLConnectionModeInPrimaryRole = $HostSQLAvailabilityReplica.ConnectionModeInPrimaryRole;
$HostSQLConnectionModeInSecondaryRole = $HostSQLAvailabilityReplica.ConnectionModeInSecondaryRole;
$HostSQLEndpointUrl = $HostSQLAvailabilityReplica.EndpointUrl;
$HostSQLFailoverMode = $HostSQLAvailabilityReplica.FailoverMode;
$HostSQLJoinState = $HostSQLAvailabilityReplica.JoinState;
$HostSQLQuorumVoteCount = $HostSQLAvailabilityReplica.QuorumVoteCount;
$HostSQLSessionTimeout = $HostSQLAvailabilityReplica.SessionTimeout;
$HostSQLBackupPriority = $HostSQLAvailabilityReplica.BackupPriority;
$HostSQLCreateDate = $HostSQLAvailabilityReplica.CreateDate;
$HostSQLDateLastModified = $HostSQLAvailabilityReplica.DateLastModified;
You can also check other properties by listing all properties of $HostSQLAvailabilityReplica.
Posted in
Windows Powershell |
No Comment | 2,361 views | 07/06/2016 00:12
You can get detailed info about SQL Server Database Replica States via following code:
1
2
3
4
5
6
7
8
9
10
11
12
| $MSSQLServerManager = New-Object 'Microsoft.SqlServer.Management.SMO.Server'
# Get SQL Database Replica States
$HostSQLDatabaseReplicaState = @($MSSQLServerManager.DatabaseReplicaStates)[0]
# Get SQL Database Replica Properties
$HostSQLReplicaGuid = $HostSQLDatabaseReplicaState .AvailabilityReplicaId;
$HostSQLDatabaseID = $HostSQLDatabaseReplicaState .DatabaseID;
$HostSQLAvailabilityReplicaServerName = $HostSQLDatabaseReplicaState .AvailabilityReplicaServerName;
$HostSQLAvailabilityDatabaseName = $HostSQLDatabaseReplicaState .AvailabilityDatabaseName;
$HostSQLReplicaAvailabilityMode = $HostSQLDatabaseReplicaState .ReplicaAvailabilityMode;
$HostSQLReplicaRole = $HostSQLDatabaseReplicaState .ReplicaRole; |
$MSSQLServerManager = New-Object 'Microsoft.SqlServer.Management.SMO.Server'
# Get SQL Database Replica States
$HostSQLDatabaseReplicaState = @($MSSQLServerManager.DatabaseReplicaStates)[0]
# Get SQL Database Replica Properties
$HostSQLReplicaGuid = $HostSQLDatabaseReplicaState .AvailabilityReplicaId;
$HostSQLDatabaseID = $HostSQLDatabaseReplicaState .DatabaseID;
$HostSQLAvailabilityReplicaServerName = $HostSQLDatabaseReplicaState .AvailabilityReplicaServerName;
$HostSQLAvailabilityDatabaseName = $HostSQLDatabaseReplicaState .AvailabilityDatabaseName;
$HostSQLReplicaAvailabilityMode = $HostSQLDatabaseReplicaState .ReplicaAvailabilityMode;
$HostSQLReplicaRole = $HostSQLDatabaseReplicaState .ReplicaRole;
You can also check other properties by listing all properties of $HostSQLDatabaseReplicaState.