This script can be used as a pre-configuration script in case if you want to attach a disk and partition it. Later use the partition as SQL Data and Log folder.
Below is the script flow:
1. Creates a log file in C:\temp folder for logging purpose.
2. Checks for the attached disks and checks for RAW partition.
3. Initializes the RAW to GPT.
4. Creates two partitions of equal size, format them to NTFS with drive letters ‘R’ and ‘S’. (Different drive letters can be provided by changing the appropriate variables)
5. Configure the SQL Server, to use, ‘R’ and ‘S’ as Data and Log directory respectively.
6. Validate the SQL Server service status.
Note: Tested and validated on SQL Server 2012
Download the Powershell script: SQL Server pre configuration