MSSQL Server

MSSQL Test Connection String With PowerShell

Quickly test a connection string with PowerShell.

$sConString = "Data Source=localhost;Integrated Security=true;Initial Catalog=master; MultipleActiveResultSets=True;" 
$oSQLCon = new-object ("Data.SqlClient.SqlConnection") $sConString 
MS Windows Server

MSCLUSTER 2008 Cluster Commandline

Display cluster resources.

cluster [group | res]
PS> [Get-ClusterGroup | Get-ClusterResource] -Cluster "<CLUSTERNAME>"
PS> Get-ClusterGroup -Cluster "<CLUSTERNAME>" | Where-Object { $_.OwnerNode -eq "<CLUSTERNODE>" } | SELECT Name

Move a cluster group to a different node.

cluster group "Cluster Group" /moveto:<NODENAME>
PS>  Move-ClusterGroup -Name "Cluster Group" -Cluster "<CLUSTERNAME>" -Node "<CLUSTERNODE>"

Display all registered nodes for a resource.

cluster res "SQL Network Name (NETWORKNAME)" /listowners
PS> Get-ClusterOwnerNode -Cluster "<CLUSTERNAME>" -Resource "<CLUSTERRESOURCE>

Bring cluster group online…

PS> Start-ClusterGroup -Name "<CLUSTERGROUPNAME>"

Switch a AlwaysOn Group to a secondary replica…

Switch-SqlAvailabilityGroup -Path SQLSERVER:\SQL\[SERVER]\[INSTANCE]|DEFAULT\AvailabilityGroups\[AOGROUP]

Change witness fileshare on a NodeAndFileMajority cluster. First change to NodeMajority and then back to NodeAndFileMajority using the new fileshare.

PS> Set-ClusterQuorum -NodeMajority
PS> Set-ClusterQuorum -NodeAndFileShareMajority \\server\fswitness$\clustername