hello all,
I am using below function to install sql server and its not working can some one help me please
Function Install-Sql2012
{
param
(
[Parameter()][string] $Path ,#= (read-host "Enter Installation Binary Path"),
[Parameter()][string] $AddSSIS= (read-host "Do u need SSIS Enter 1 for yes o for no") ,
[Parameter()][string] $AddSSRS= (read-host "Do u need SSRS Enter 1 for yes o for no") ,
[Parameter()][string] $InstanceName = (read-host "Enter Instance name"),
[Parameter()][string] $ServiceAccount= (read-host "Enter Service Account"),
[Parameter()][string] $ServicePassword= (read-host -assecurestring "Enter Service Account Password") ,
[Parameter()][string] $AgentAccount=(read-host "Enter Agent Account"),
[Parameter()][string] $AgentPassword=(read-host "Enter Agent pasword"),
[Parameter()][string] $Backuppath= (read-host "Enter Backuppath"),
[Parameter()][string] $SaPassword= (read-host -assecurestring "Enter SA Account Passowrd"),
[Parameter()][string] $SQLTEMPDBDIR= (read-host "Enter TempDir"),
[Parameter()][string] $SQLUSERDBDIR= (read-host "Enter User Data Directory"),
[Parameter()][string] $SQLUSERDBLOGDIR= (read-host "Enter User Log Directory"),
#[Parameter(Position=5,Mandatory=$false)][string] $LicenseKey,
[Parameter()][string] $SqlCollation = "SQL_Latin1_General_CP1_CI_AS",
[Parameter()][switch] $NoTcp,
[Parameter()][switch] $NoNamedPipes
)
#Build the setup command using the install mode
if ($Path -eq $null -or $Path -eq "")
{
#No path means that the setup is in the same folder
$command = '.\setup.exe /Action="Install"'
}
else
{
#Ensure that the path ends with a backslash
if(!$Path.EndsWith("\"))
{
$Path += "\"
}
$command = $path + 'setup.exe /Action="Install"'
}
#Accept the license agreement - required for command line installs
$command += ' /IACCEPTSQLSERVERLICENSETERMS'
#Use the QuietSimple mode (progress bar, but not interactive)
$command += ' /QS'
#Set the features to be installed
#$command += ' /FEATURES=SQLENGINE,CONN,BC,SSMS,ADV_SSMS'
If ($AddSSIS -ne '0' -and $AddSSIS -ne '1') {
throw 'Invalid input. Enter a valid value for SSIS.'
}
If ($AddSSRS -ne '0' -and $AddSSRS -ne '1') {
throw 'Invalid input. Enter a valid value for SSRS.'
}
if ($AddSSIS -eq 1 -and $AddSSRS -eq 1)
{
$command += ' /FEATURES=SQLENGINE,CONN,BC,SSMS,ADV_SSMS,SSIS,SSRS'
}
if ($AddSSIS -eq 1 -and $AddSSRS -eq 0)
{
$command += ' /FEATURES=SQLENGINE,CONN,BC,SSMS,ADV_SSMS,SSIS'
}
if ($AddSSIS -eq 0 -and $AddSSRS -eq 1)
{
$command += ' /FEATURES=SQLENGINE,CONN,BC,SSMS,ADV_SSMS,SSRS'
}
if ($AddSSIS -eq 0 -and $AddSSRS -eq 0)
{
$command += ' /FEATURES=SQLENGINE,CONN,BC,SSMS,ADV_SSMS'
}
#Set the Instance Name
$command += (' /INSTANCENAME="{0}"' -f $InstanceName)
#remove Set the License Key only if a value was provided, otherwise install Evaluation edition
#if ($LicenseKey -ne $null -and $LicenseKey -ne "")
#{
#$command += (' /PID="{0}"' -f $LicenseKey)
#}
#set reporting to off
$command += ('/SQMREPORTING="0"')
#Add Browser Account
$command +=('/BROWSERSVCSTARTUPTYPE="Disabled"')
#Add Backup path
$command +=('/SQLBACKUPDIR="{0}"' -f $backuppath)
#Check to see if a service account was specified
if ($ServiceAccount -ne $null -and $ServiceAccount -ne "")
{
#Set the database engine service account
$command += (' /SQLSVCACCOUNT="{0}" /SQLSVCPASSWORD="{1}" /SQLSVCSTARTUPTYPE="Automatic"' -f $ServiceAccount, $ServicePassword)
#Set the SQL Agent service account
$command += (' /AGTSVCACCOUNT="{0}" /AGTSVCPASSWORD="{1}" /AGTSVCSTARTUPTYPE="Automatic"' -f $AgentAccount, $AgentPassword)
}
else
{
#Set the database engine service account to Local System
$command += ' /SQLSVCACCOUNT="NT AUTHORITY\SYSTEM" /SQLSVCSTARTUPTYPE="Automatic"'
#Set the SQL Agent service account to Local System
$command += ' /AGTSVCACCOUNT="NT AUTHORITY\SYSTEM" /AGTSVCSTARTUPTYPE="Automatic"'
}
#Set the server in SQL authentication mode if an SA password was provided
if ($SaPassword -ne $null -and $SaPassword -ne "")
{
$command += (' /SECURITYMODE="SQL" /SAPWD="{0}"' -f $SaPassword)
}
#Add current user as SysAdmin
$command += (' /SQLSYSADMINACCOUNTS="test\ADMIN"')
#Add Tempdbdata path
$command += (' /SQLTEMPDBDIR="{0}"' -f $SQLTEMPDBDIR)
#Add Tempdblog path
$command += (' /SQLTEMPDBLOGDIR="{0}"' -f $SQLTEMPDBDIR)
#Add UserDBdata path
$command += (' /SQLUSERDBDIR="{0}"' -f $SQLUSERDBDIR)
#Add UserDBlog path
$command += (' /SQLUSERDBLOGDIR="{0}"' -f $SQLUSERDBLOGDIR)
#Set the database collation
$command += (' /SQLCOLLATION="{0}"' -f $SqlCollation)
#Enable/Disable the TCP Protocol
if ($NoTcp)
{
$command += ' /TCPENABLED="0"'
}
else
{
$command += ' /TCPENABLED="1"'
}
#Enable/Disable the Named Pipes Protocol
if ($NoNamedPipes)
{
$command += ' /NPENABLED="0"'
}
else
{
$command += ' /NPENABLED="1"'
}
if ($PSBoundParameters['Debug'])
{
Write-Output $command
}
else
{
Invoke-Expression $command
}
}
Install-Sql2012
Below is the error i am getting
PS C:\temp\in> .\Install-Sql2012.ps1
Do u need SSIS Enter 1 for yes o for no: 0
Do u need SSRS Enter 1 for yes o for no: 0
Enter Instance name: MSSQLSERVER
Enter Service Account:
Enter Service Account Password:
Enter Agent Account:
Enter Agent pasword:
Enter Backuppath: "C:\Temp\IN\bck"
Enter SA Account Passowrd: **********
Enter TempDir: "C:\Temp\IN\bck"
Enter User Data Directory: "C:\Temp\IN\bck"
Enter User Log Directory: "C:\Temp\IN\bck"
Microsoft (R) SQL Server 2012 11.00.2100.60
Copyright (c) Microsoft Corporation. All rights reserved.
The following error occurred:
Instance name is limited to 16 characters. Yours 'MSSQLSERVER/SQMREPORTING=0/BROWSERSVCSTARTUPTYPE=DISABLED/SQLBACKUPDIR=C:\TEMP\IN\BCK' is 85.
Error result: -2054422513
Result facility code: 1420
Result error code: 15
Please review the summary.txt log for further details
Thanks,
Ashwin.