$SqlServerSetupLocation = "<path to SQL Server 2014 setup.exe>"
# Replace "<InstanceName>" with the desired instance name
$InstanceName = "<InstanceName>"
# Replace "<SQLServerDataPath>" with the desired data path
$SqlDataDir = "<SQLServerDataPath>"
# Replace "<SQLServerLogPath>" with the desired log path
$SqlLogDir = "<SQLServerLogPath>"
# Replace "<SQLServerBackupPath>" with the desired backup path
$SqlBackupDir = "<SQLServerBackupPath>"
# Replace "<SQLServerTempdbPath>" with the desired tempdb path
$SqlTempdbDir = "<SQLServerTempdbPath>"
$SqlSysAdminAccounts = @("<sysadmin-account-1>", "<sysadmin-account-2>")
$ConfigurationFile = "ConfigurationFile.ini" # Provide the path to an existing configuration file or create a new one
# Replace "<SQLServerInstallerUsername>" and "<SQLServerInstallerPassword>" with appropriate credentials
$SqlServerInstallerCredential = Get-Credential -Credential "<SQLServerInstallerUsername>"
$SetupArguments = @(
"/QS", # Quiet mode
"/IACCEPTSQLSERVERLICENSETERMS", # Accept license terms
"/ACTION=Install", # Install SQL Server
"/INSTANCEID=$InstanceName", # Instance ID
"/INSTANCENAME=$InstanceName", # Instance name
"/FEATURES=SQL,Tools", # Install SQL Server engine and tools
"/SQLSVCACCOUNT='NT AUTHORITY\NETWORK SERVICE'", # Service account
"/SQLSYSADMINACCOUNTS=$SqlSysAdminAccounts", # SQL Server sysadmin accounts
"/SQLCOLLATION='SQL_Latin1_General_CP1_CI_AS'", # SQL Server collation (modify if needed)
"/SQLSVCSTARTUPTYPE=Automatic", # SQL Server service startup type
"/AGTSVCACCOUNT='NT AUTHORITY\NETWORK SERVICE'", # SQL Server Agent service account
"/SQLUSERDBDIR=$SqlDataDir", # Data directory
"/SQLUSERDBLOGDIR=$SqlLogDir", # Log directory
"/SQLBACKUPDIR=$SqlBackupDir", # Backup directory
"/SQLTEMPDBDIR=$SqlTempdbDir", # TempDB directory
"/SECURITYMODE=SQL", # Security mode (SQL Server authentication)
"/SAPWD='<StrongPasswordHere>'" # SQL Server sa password
)
# Start the SQL Server 2014 installation using the specified configuration file and setup arguments
Start-Process -FilePath $SqlServerSetupLocation -Wait -Credential $SqlServerInstallerCredential -ArgumentList ("/ConfigurationFile=$ConfigurationFile", $SetupArguments)