SQL

$Destination ==>This is the folder where backup files will be stored
$Retension ==> Number of days to keep backup files. Backup files older than this will be deleted. If you don’t want any files deleted, make this number high like 99999

The script creates a folder for each database under the $Destination folder. Backup file name contains the database name and date/time of backup. For example, for database ‘INM’, backup file would be ‘H:\SQL-Backup\INM\INM-20160605_081237AM.bak’
Script returns an object collection. Each object has the following properties:

SQL mirroring is a popular DR option for SQL databases. It provides a warm standby server where a database can be recovered quickly. Although SQL mirroring is being deprecated by Microsoft in SQL 2016 in lieu of Availability Groups, they share several elements of the underlying technologies.

SQL mirroring popularity is often attributed to

It does not require shared storage like clustering

It does not require a common file share like log-shipping

It can be configured for automatic failover (synchronous mode only) with the configuration of a SQL Witness (3rd server). This option requires that the application/client be mirror-aware (include ‘failover partner=xxxx’ in connection string)

It can be configured in safety/synchronous mode (default), where a transaction is written to both servers before a commit is returned to the client. This requires low latency between the 2 servers.

It can be configured in performance/asynchronous mode, where the primary server sends commit back to client as soon as the transaction is written to the send queue. This may lose data if the primary fails before the transaction makes it to the secondary server redo queue.

It can be configured across distant geographical locations (recommend asynchronous mode and certificate based authentication in this scenario)

It can be configured between 2 servers that belong to different AD domains using certificate authentication.

SELECT * FROM sys.sysusers where name = ‘Vertitech1SQL2_user’SELECT * FROM sys.server_principals where name = ‘Vertitech1SQL2_login’SELECT * FROM sys.certificates SELECT name,port FROM sys.tcp_endpoints

SELECT * FROM sys.sysusers where name = ‘Vertitech1SQL1_user’SELECT * FROM sys.server_principals where name = ‘Vertitech1SQL1_login’SELECT * FROM sys.certificates SELECT name,port FROM sys.tcp_endpoints

This script needs SQLPS module. This is installed by default with SQL 2012 and higher versions. If you’re using an older SQL version, you need to download and install the following 3 components in order:

If you need to move the SQL Temp database and log files to a new drive/folder, you need to run a few SQL queries and restart SQL service. The following script automates this task. This can be particularly useful if you need to do this task for many SQL servers.

This script needs SQLPS module. This is installed by default with SQL 2012 and higher versions. If you’re using an older SQL version, you need to download and install the following 3 components in order:

I’ve linked to the x64 versions of these files, but you need to get the version that matches your OS.

You also need to remember to run the command:

Import-Module SQLPS

then close ISE and reopen it again. After that you can run the script.

You need to edit lines 6 and 7 to enter the new locations of where you’d like to move the Temp DB and Log files. Make sure the necessary folder exists before you run the script (h:\SQL-Temp folder in this example).