This is a set of functions I've created for working with our many SQL servers. Does not use PSSQL or SMO, and requires no prerequisites to use. All blindingly fast SQL queries. Includes several functions for getting status of Availability Groups.
- Download this repo, Unblock the file(s), copy the Surly.PowerShell.SQL.Tools folder to an appropriate module location
- Import-Module pathToRepo\Surly.PowerShell.SQL.Tools
- Get-Command -Module Surly.PowerShell.SQL.Tools
- Invoke-SQLQuery
- Get-AGCluster
- Get-AGDatabaseState
- Get-AGReplicaState
- Get-ClusterGroupRemote (see below)
- Get-SQLAuthenticationScheme
- Get-SQLBackupFileName
- Get-SQLBackupStatus
- Get-SQLJobStatus
- Move-ClusterGroupRemote (see below)
- New-SQLBackupStatusReport
- New-SQLJobStatusReport
- Resize-SQLLogFile
- Set-AGClusterFailover
- Set-GroupRowColorsByColumn (see below)
These are not strictly SQL functions, but are designed to failover Windows Failover Cluster Groups (or retrieve data about them) and can be used with any Windows Cluster, not just SQL Availability Groups.
This is a HTML enhancement function that will change the CSS class of a background row based on the value of one of the columns. I use it to change the background color whenever the name of a server changes.
Please read the CONTRIBUTING.md file for contributing guidelines
Functionalize New-SQLBackupReport and New-SQLJobsReport- Set-AGClusterFailover fully functional for failover between synchronous nodes. Need to code/test the DR flags and failover to asynchronous nodes.