Advertisement
Dennisaa

SQL Server silent install

May 21st, 2015
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # don't know who did this - credit to them
  2. ###################################################################################
  3. ### SCRIPT GENERATES INI FILES WHICH CAN BE USED TO PERFORM UNATTENDED INSTALLS ###
  4. ### OF SQL SERVER. NOTE: This script assumes that the product key is packaged   ###
  5. ### with the installation media.                                                ###
  6. ###################################################################################
  7.  
  8. ###################################################################################
  9. ###                             Help Context                                    ###
  10. ###################################################################################
  11.  
  12. <#
  13. .SYNOPSIS
  14. This script will create the configuration.ini file(s) necessary for an unattended or silent
  15. installation of MS SQL Server 2008 / 2008 R2 as a Stand-A-Lone Instance or a Windows Fail-Over Cluster.
  16.  
  17. .DESCRIPTION
  18. This script is designed to be a start to finish solution for unattended or silent installations
  19. of MS SQL Server 2008 / 2008 R2. The script has certain defaults registered within it that
  20. you can optionally select for expediancy in entering the necessary information. It will then walk you
  21. through a number of questions specific to the cluster that you are installing this instance on and
  22. then create the necessary configuration.ini files. At the end you will be able to command PowerShell
  23. to execute the installation right then or you can request that the execution command be printed and
  24. copied to your clipboard for future use.
  25.  
  26. .EXAMPLE
  27. .\InstallSQL_Silent.ps1
  28.  
  29. .NOTES
  30. At this time SSRS and SSAS features are not supported and this script has only been tested on MS SQL
  31. Server 2008 and 2008 R2 instances. Support for upgrades is also not included.
  32.  
  33. .INPUTS
  34. None.
  35.  
  36. .OUTPUTS
  37. None.
  38. #>
  39.  
  40. ################
  41. ####Includes####
  42. ################
  43.  
  44. #load windows form assembly
  45. [reflection.assembly]::loadwithpartialname('system.windows.forms') | Out-Null;
  46.  
  47. #Instantiates a new com object we'll use for choosing folders
  48. $object = New-Object -comObject Shell.Application
  49.  
  50. #setup clipboard alias
  51. IF ((get-alias | where-object {$_.name -eq "out-clipboard"} | select name) -NotLike "*out-clipboard*")
  52. {
  53.     new-alias  Out-Clipboard $env:SystemRoot\system32\clip.exe
  54. }
  55.  
  56. ################
  57. ###Functions####
  58. ################
  59.  
  60. #See if the user wants to use standard/default responses for some options
  61. function UseDefaults()
  62. {
  63.     $Yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes","By selecting yes you will be allowing this script to skip certain questions where there are registered defaults and skip all informational messages. For example, regarding services accounts you will be asked what environment this install is for but not the service accounts. Those will be populated automatically."
  64.     $No = New-Object System.Management.Automation.Host.ChoiceDescription "&No","By selecting no you will be given the full opportunity to select every configuration and set variables manually."
  65.     $choices = [System.Management.Automation.Host.ChoiceDescription[]]($Yes,$No)
  66.     $caption = "Question!"
  67.     $message = "Would you like to use minimal install with default options for choices where applicable?"
  68.     $DefaultChoice = $Host.UI.PromptForChoice($caption,$message,$choices,0)
  69.  
  70.     switch ($DefaultChoice)
  71.     {
  72.         0 {$Script:DefaultChoice = "YES"}
  73.         1 {$Script:DefaultChoice = "NO"}
  74.     }
  75. }
  76.  
  77. #welcome message
  78. function WelcomeMessage([string]$SkipMessage)
  79. {
  80.     if ($Script:SkipMessage -eq "NO")
  81.     {
  82.         #Let the user know what this script does
  83.         [system.Windows.Forms.MessageBox]::show("You are about to create ini files that can be used to automate installation of SQL instances into a cluster and then (optionally) initiate the setup sequence.
  84.                
  85. When choosing to create the ini for a new clustered instance it will also create the ini file used to add nodes to that cluster.
  86.  
  87. The ini files can be renamed when they are completed.
  88.         ")
  89.     }
  90. }
  91.  
  92. #identify which environment to set service accounts
  93. function SelectEnvironment([string]$UseDefaults)
  94. {
  95.     if ($UseDefaults -eq "YES")
  96.     {
  97.         $Dev = New-Object System.Management.Automation.Host.ChoiceDescription "&Dev","Select Dev if this configuration is for a development instance."
  98.         $SIT = New-Object System.Management.Automation.Host.ChoiceDescription "&SIT","Select SIT if this configuration is for a SIT instance."
  99.         $QA = New-Object System.Management.Automation.Host.ChoiceDescription "&QA","Select QA if this configuration is for a QA instance."
  100.         $Production = New-Object System.Management.Automation.Host.ChoiceDescription "&Prod","Select Prod if this configuration is for a production instance."
  101.         $choices = [System.Management.Automation.Host.ChoiceDescription[]]($Dev,$SIT,$QA,$Production)
  102.         $caption = "Question!"
  103.         $message = "Which environment is this configuration for?"
  104.         $EnvironmentSelection = $Host.UI.PromptForChoice($caption,$message,$choices,3)
  105.        
  106.         switch ($EnvironmentSelection)
  107.         {
  108.             0 {$Script:EnvironmentSelection="DEV"}
  109.             1 {$Script:EnvironmentSelection="SIT"}
  110.             2 {$Script:EnvironmentSelection="QA"}
  111.             3 {$Script:EnvironmentSelection="PRODUCTION"}
  112.         }
  113.     }
  114. }
  115.  
  116. #Set variables for file naming
  117. function SetFilePath()
  118. {
  119.     #Grab the current user and current time, we'll use these to create the file
  120.     $CurrUser = [Security.Principal.WindowsIdentity]::GetCurrent() | select Name
  121.     $Script:FileCreator = $CurrUser.Name
  122.     $Script:CurrDate = (Get-Date -UFormat "%Y-%m-%d %H:%M")
  123.     $CurrDateSanitized = $CurrDate -replace ":",""
  124.  
  125.     #Strip out the domain from the user account
  126.     if ($FileCreator -ilike "*\*")
  127.     {
  128.         $string = $FileCreator.Split("\")
  129.         $FilePart1 = ($string[1]) -replace "\.", " "
  130.         $FilePart1 = (Get-Culture).TextInfo.ToTitleCase($FilePart1)
  131.     }
  132.     else
  133.     {
  134.         $FilePart1 = (Get-Culture).TextInfo.ToTitleCase($FileCreator)
  135.     }
  136.  
  137.     #Current user + date time = filename   
  138.     $Script:FileName = $FilePart1+" "+$CurrDateSanitized+" New Instance.ini"
  139.     $Script:FileNameAddNode = $FilePart1+" "+$CurrDateSanitized+" Add Node.ini"
  140.        
  141.     #Ask the user for the path where they want to put the ini file 
  142.     $inifolder = $object.BrowseForFolder(0, "Please choose the folder where you wish to put the INI file", 0)
  143.     if ($inifolder -ne $null)
  144.     {
  145.         $ini = $inifolder.self.Path
  146.         #if we use a root drive we need to remove the \
  147.         $iniRoot =$inifolder.Self.Type
  148.         if ($iniRoot -eq "Local Disk")
  149.         {
  150.             $ini = $ini -replace "\\",""
  151.         }
  152.         $Script:file = $ini +"\"+ $fileName
  153.         $Script:FileNameAddNode = $ini +"\"+ $FileNameAddNode
  154.     }
  155. }
  156.  
  157. #Create choices for whether we want to install a new clustered instance or add a node
  158. function SetInstallationType()
  159. {
  160.     $InstallCluster = New-Object System.Management.Automation.Host.ChoiceDescription "&New Clustered Instance","By selecting this option you will generate two ini files. One for the new instance installation and one to add a node."
  161.     $AddNode = New-Object System.Management.Automation.Host.ChoiceDescription "&Add Node To Cluster","By selecting this option you will skip several irrelevant questions and only generate one ini file designed for adding a node to an existing instance."
  162.     $StandAlone = New-Object System.Management.Automation.Host.ChoiceDescription "New &Stand Alone Instance","By selecting this option you will generate one ini file necessary to install your instance."
  163.     $choices = [System.Management.Automation.Host.ChoiceDescription[]]($InstallCluster,$AddNode,$StandAlone)
  164.     $caption = "Question!"
  165.     $message = "Install new clustered instance or add node to existing cluster?"
  166.     $InstallChoice = $Host.UI.PromptForChoice($caption,$message,$choices,0)
  167.  
  168.     switch ($InstallChoice)
  169.     {
  170.         0 {$Script:InstallChoice="INSTALLCLUSTER"}
  171.         1 {$Script:InstallChoice="ADDNODE"}
  172.         2 {$Script:InstallChoice="STANDALONEINSTALL"}
  173.     }
  174. }
  175.  
  176. #Set non-configurable options
  177. function WriteNonConfigurableOptions([string]$InstallType)
  178. {
  179.     #Install specific settings
  180.     switch ( $InstallChoice )
  181.     {
  182.         "STANDALONEINSTALL"
  183.         {
  184.             #Default settings
  185.             ";File created by: $FileCreator" | Out-File $file
  186.             ";File creation date: $CurrDate" | Out-File $file -Append
  187.            
  188.             ";Script to install new SQL clustered instance" | Out-file $file -Append
  189.             ";SQLSERVER2008 Configuration File" | Out-file $file -Append
  190.             "" | Out-File $file -Append
  191.             "[SQLSERVER2008]" | Out-File $file -Append
  192.             "" | Out-File $file -Append
  193.            
  194.             "IACCEPTSQLSERVERLICENSETERMS=`"TRUE`"" | Out-File $file -Append
  195.            
  196.             "HELP=`"False`"" |  Out-File $file -Append
  197.             "INDICATEPROGRESS=`"True`"" |  Out-File $file -Append
  198.             "QUIET=`"False`"" |  Out-File $file -Append
  199.             "QUIETSIMPLE=`"True`"" |  Out-File $file -Append
  200.             "X86=`"False`"" |  Out-File $file -Append
  201.             "ENU=`"True`"" |  Out-File $file -Append
  202.             "FTSVCACCOUNT=`"NT AUTHORITY\LOCAL SERVICE`"" |  Out-File $file -Append
  203.        
  204.             #SQL binaries location (in this case to C: I usually use D:)
  205.             "INSTALLSHAREDDIR=`"C:\Program Files\Microsoft SQL Server`"" |  Out-File $file -Append
  206.             "INSTALLSHAREDWOWDIR=`"C:\Program Files (x86)\Microsoft SQL Server`"" |  Out-File $file -Append
  207.             "INSTANCEDIR=`"C:\Program Files\Microsoft SQL Server`"" |  Out-File $file -Append
  208.            
  209.             #Installing new cluster
  210.             "ACTION=`"Install`"" |  Out-File $file -Append
  211.  
  212.             #Default settings
  213.             "ERRORREPORTING=`"False`"" |  Out-File $file -Append
  214.             "SQMREPORTING=`"False`"" |  Out-File $file -Append
  215.             "FILESTREAMLEVEL=`"0`"" |  Out-File $file -Append
  216.             "ISSVCSTARTUPTYPE=`"Automatic`"" |  Out-File $file -Append
  217.             "ISSVCACCOUNT=`"NT AUTHORITY\NetworkService`"" |  Out-File $file -Append
  218.             "SQLCOLLATION=`"SQL_Latin1_General_CP1_CI_AS`"" |  Out-File $file -Append
  219.             "AGTSVCSTARTUPTYPE=`"Automatic`"" |  Out-File $file -Append
  220.             "SQLSVCSTARTUPTYPE=`"Automatic`"" |  Out-File $file -Append
  221.             "BROWSERSVCSTARTUPTYPE=`"Automatic`"" |  Out-File $file -Append
  222.             "TCPENABLED=`"1`"" |  Out-File $file -Append
  223.         }
  224.         "INSTALLCLUSTER"
  225.         {
  226.             #Default settings
  227.             ";File created by: $FileCreator" | Out-File $file
  228.             ";File creation date: $CurrDate" | Out-File $file -Append
  229.            
  230.             ";Script to install new SQL clustered instance" | Out-file $file -Append
  231.             ";SQLSERVER2008 Configuration File" | Out-file $file -Append
  232.             "" | Out-File $file -Append
  233.             "[SQLSERVER2008]" | Out-File $file -Append
  234.             "" | Out-File $file -Append
  235.            
  236.             "IACCEPTSQLSERVERLICENSETERMS=`"TRUE`"" | Out-File $file -Append
  237.            
  238.             "HELP=`"False`"" |  Out-File $file -Append
  239.             "INDICATEPROGRESS=`"True`"" |  Out-File $file -Append
  240.             "QUIET=`"False`"" |  Out-File $file -Append
  241.             "QUIETSIMPLE=`"True`"" |  Out-File $file -Append
  242.             "X86=`"False`"" |  Out-File $file -Append
  243.             "ENU=`"True`"" |  Out-File $file -Append
  244.             "FTSVCACCOUNT=`"NT AUTHORITY\LOCAL SERVICE`"" |  Out-File $file -Append
  245.        
  246.             #SQL binaries location (in this case to C: I usually use D:)
  247.             "INSTALLSHAREDDIR=`"C:\Program Files\Microsoft SQL Server`"" |  Out-File $file -Append
  248.             "INSTALLSHAREDWOWDIR=`"C:\Program Files (x86)\Microsoft SQL Server`"" |  Out-File $file -Append
  249.             "INSTANCEDIR=`"C:\Program Files\Microsoft SQL Server`"" |  Out-File $file -Append
  250.            
  251.             #Installing new cluster
  252.             "ACTION=`"InstallFailoverCluster`"" |  Out-File $file -Append
  253.  
  254.             #Default settings
  255.             "ERRORREPORTING=`"False`"" |  Out-File $file -Append
  256.             "SQMREPORTING=`"False`"" |  Out-File $file -Append
  257.             "FILESTREAMLEVEL=`"0`"" |  Out-File $file -Append
  258.             "ISSVCSTARTUPTYPE=`"Automatic`"" |  Out-File $file -Append
  259.             "ISSVCACCOUNT=`"NT AUTHORITY\NetworkService`"" |  Out-File $file -Append
  260.             "SQLCOLLATION=`"SQL_Latin1_General_CP1_CI_AS`"" |  Out-File $file -Append
  261.         }
  262.         "ADDNODE"
  263.         {
  264.             #Default settings
  265.             ";File created by: $FileCreator" | Out-File $FileNameAddNode
  266.             ";File creation date: $CurrDate" | Out-File $FileNameAddNode -Append
  267.            
  268.             ";Script to install new SQL clustered instance" | Out-file $FileNameAddNode -Append
  269.             ";SQLSERVER2008 Configuration File" | Out-file $FileNameAddNode -Append
  270.             "" | Out-File $FileNameAddNode -Append
  271.             "[SQLSERVER2008]" | Out-File $FileNameAddNode -Append
  272.             "" | Out-File $FileNameAddNode -Append
  273.                    
  274.             "IACCEPTSQLSERVERLICENSETERMS=`"TRUE`"" | Out-File $FileNameAddNode -Append
  275.            
  276.             "HELP=`"False`"" |  Out-File $FileNameAddNode -Append
  277.             "INDICATEPROGRESS=`"True`"" |  Out-File $FileNameAddNode -Append
  278.             "QUIET=`"False`"" |  Out-File $FileNameAddNode -Append
  279.             "QUIETSIMPLE=`"True`"" |  Out-File $FileNameAddNode -Append
  280.             "X86=`"False`"" |  Out-File $FileNameAddNode -Append
  281.             "ENU=`"True`"" |  Out-File $FileNameAddNode -Append
  282.             "FTSVCACCOUNT=`"NT AUTHORITY\LOCAL SERVICE`"" |  Out-File $FileNameAddNode -Append
  283.        
  284.             #Adding a new node
  285.             "ACTION=`"AddNode`"" | Out-File $FileNameAddNode -Append
  286.         }
  287.         default
  288.         {
  289.             Write-Error "Installation choice not recognized."
  290.         }
  291.     }
  292. }
  293.  
  294. #Set SQL virtual network name, Instance name, and IP
  295. function ConfigureInstanceOptions([string]$InstallType)
  296. {
  297.     switch ( $InstallChoice )
  298.     {
  299.         "STANDALONEINSTALL"
  300.         {
  301.             #SQL Instance Name or default
  302.             $Yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes","By selecting this option you will install a default instance by the name of `"MSSQLServer`"."
  303.             $No = New-Object System.Management.Automation.Host.ChoiceDescription "&No","By selecting this option you will install an instance with a name that you choose."
  304.             $choices = [System.Management.Automation.Host.ChoiceDescription[]]($Yes,$No)
  305.             $caption = "Question!"
  306.             $message = "Is this going to be a default instance?"
  307.             $IsDefaultInstance = $Host.UI.PromptForChoice($caption,$message,$choices,1)
  308.  
  309.             switch ($IsDefaultInstance)
  310.             {
  311.                 0 {$Script:IsDefaultInstance="YES"}
  312.                 1 {$Script:IsDefaultInstance="NO"}
  313.             }
  314.            
  315.             if ( $IsDefaultInstance -eq "YES" )
  316.             {
  317.                 $Script:SQLInstanceName = "MSSQLSERVER"
  318.                 "INSTANCENAME=`"$SQLInstanceName`"" |  Out-File $file -Append
  319.                 "INSTANCEID=`"$SQLInstanceName`"" |  Out-File $file -Append
  320.             }
  321.             else
  322.             {
  323.                 $SQLInstanceName = Read-Host "Enter the SQL instance name
  324.     ie: CLDB001A"
  325.                 $Script:SQLInstanceName = $SQLInstanceName.ToUpper()
  326.                 "INSTANCENAME=`"$SQLInstanceName`"" |  Out-File $file -Append
  327.                 "INSTANCEID=`"$SQLInstanceName`"" |  Out-File $file -Append
  328.             }
  329.         }
  330.         "INSTALLCLUSTER"
  331.         {
  332.             #SQL Virtual Name
  333.             $SQLVirtualName = read-host "Enter the SQL virtual network name
  334.     ie: CL-DB-001-A"
  335.             $Script:SQLVirtualName = $SQLVirtualName.ToUpper()
  336.             "FAILOVERCLUSTERNETWORKNAME=`"$SQLVirtualName`"" | Out-File $file -Append
  337.                
  338.             #SQL Instance Name (will also use for Instance ID and failover cluster group)
  339.             $SQLInstanceName = Read-Host "Enter the SQL instance name
  340.     ie: CLDB001A"
  341.             $Script:SQLInstanceName = $SQLInstanceName.ToUpper()
  342.             "INSTANCENAME=`"$SQLInstanceName`"" |  Out-File $file -Append
  343.             "INSTANCEID=`"$SQLInstanceName`"" |  Out-File $file -Append
  344.             "FAILOVERCLUSTERGROUP=`"$SQLVirtualName`"" |  Out-File $file -Append
  345.  
  346.             #IPAddress (running IPV4 only and will use default 255.255.0.0 subnet)
  347.             $IPAddress = Read-Host "Enter the IP Address (IPv4 only)"
  348.             "FAILOVERCLUSTERIPADDRESSES=`"IPv4;$IPAddress`;Cluster Network 1;255.255.0.0`""  |  Out-File $file -Append
  349.         }
  350.         "ADDNODE"
  351.         {
  352.             #SQL Virtual Name
  353.             $SQLVirtualName = read-host "Enter the SQL virtual network name
  354.             ie: CL-DB-001-A"
  355.             $Script:SQLVirtualName = $SQLVirtualName.ToUpper()
  356.             "FAILOVERCLUSTERNETWORKNAME=`"$SQLVirtualName`"" | Out-File $FileNameAddNode -Append
  357.  
  358.             #SQL Instance Name (will also use for Instance ID and failover cluster group)
  359.             $SQLInstanceName = Read-Host "Enter the SQL instance name
  360.             ie: CLDB001A"
  361.             $Script:SQLInstanceName = $SQLInstanceName.ToUpper()
  362.             "INSTANCENAME=`"$SQLInstanceName`"" |  Out-File $FileNameAddNode -Append
  363.             "FAILOVERCLUSTERGROUP=`"$SQLVirtualName`"" |  Out-File $FileNameAddNode -Append
  364.         }
  365.         default
  366.         {
  367.             Write-Error "Installation choice not recognized."
  368.         }
  369.     }
  370. }
  371.  
  372. function SetFeatures([string]$UseDefaults)
  373. {
  374.     #The SQLENGINE is always installed for this script.
  375.     $Features = "FEATURES=SQLENGINE"
  376.    
  377.     IF ($UseDefaults -eq "NO")
  378.     {
  379.         ##REPLICATION
  380.         $Yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes","Selecting yes you will command this installation to install replication as one of its features. NOTE: If replication is already installed for this instance then the installation will throw errors."
  381.         $No = New-Object System.Management.Automation.Host.ChoiceDescription "&No","Selecting no you will command this installation to omit replication from the feature set."
  382.         $choices = [System.Management.Automation.Host.ChoiceDescription[]]($Yes,$No)
  383.         $caption = "Question!"
  384.         $message = "Would you like to have REPLICATION installed?"
  385.         $FeatureChoice = $Host.UI.PromptForChoice($caption,$message,$choices,0)
  386.        
  387.         if ($FeatureChoice -eq 0)
  388.         {
  389.             $Features = $Features + ",REPLICATION"
  390.         }
  391.     }
  392.     ELSE
  393.     {
  394.         $Features = $Features + ",REPLICATION"
  395.     }
  396.     IF ($UseDefaults -eq "NO")
  397.     {
  398.         ##FULLTEXT
  399.         $Yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes","Selecting yes you will command this installation to install full-text search as one of its features. NOTE: If full-text search is already installed for this instance then the installation will throw errors."
  400.         $No = New-Object System.Management.Automation.Host.ChoiceDescription "&No","Selecting no you will command this installation to omit full-text search from the feature set."
  401.         $choices = [System.Management.Automation.Host.ChoiceDescription[]]($Yes,$No)
  402.         $caption = "Question!"
  403.         $message = "Would you like to have FULLTEXT installed?"
  404.         $FeatureChoice = $Host.UI.PromptForChoice($caption,$message,$choices,0)
  405.        
  406.         if ($FeatureChoice -eq 0)
  407.         {
  408.             $Features = $Features + ",FULLTEXT"
  409.         }
  410.     }
  411.     ELSE
  412.     {
  413.         $Features = $Features + ",FULLTEXT"
  414.     }
  415.     IF ($UseDefaults -eq "NO")
  416.     {
  417.         ##BIDS
  418.         $Yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes","Selecting yes you will command this installation to install Business Intelligence Developer Studio as one of its features. NOTE: If BIDS is already installed for this instance then the installation will throw errors."
  419.         $No = New-Object System.Management.Automation.Host.ChoiceDescription "&No","Selecting no you will command this installation to omit Business Intelligence Developer Studio from the feature set."
  420.         $choices = [System.Management.Automation.Host.ChoiceDescription[]]($Yes,$No)
  421.         $caption = "Question!"
  422.         $message = "Would you like to have BUSINESS INTELLIGENCE DEVELOPMENT STUDIO installed?"
  423.         $FeatureChoice = $Host.UI.PromptForChoice($caption,$message,$choices,0)
  424.        
  425.         if ($FeatureChoice -eq 0)
  426.         {
  427.             $Features = $Features + ",BIDS"
  428.         }
  429.     }
  430.     else
  431.     {
  432.         if (($EnvironmentSelection -eq "DEV") -OR ($EnvironmentSelection -eq "SIT"))
  433.         {
  434.             $Features = $Features + ",BIDS"
  435.         }
  436.     }
  437.     IF ($UseDefaults -eq "NO")
  438.     {
  439.         ##IS
  440.         $Yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes","Selecting yes you will command this installation to install integration services as one of its features. NOTE: If integration services is already installed for this cluster then the installation will throw errors."
  441.         $No = New-Object System.Management.Automation.Host.ChoiceDescription "&No","Selecting no you will command this installation to omit integration services from the feature set. Integration services is only necessary for remote management of stored SSIS packages and is not necessary for execution."
  442.         $choices = [System.Management.Automation.Host.ChoiceDescription[]]($Yes,$No)
  443.         $caption = "Question!"
  444.         $message = "Would you like to have INTEGRATED SERVICES installed?"
  445.         $FeatureChoice = $Host.UI.PromptForChoice($caption,$message,$choices,0)
  446.  
  447.         if ($FeatureChoice -eq 0)
  448.         {
  449.             $Features = $Features + ",IS"
  450.         }
  451.     }
  452.     else
  453.     {
  454.         if (($EnvironmentSelection -eq "DEV") -OR ($EnvironmentSelection -eq "SIT"))
  455.         {
  456.             $Features = $Features + ",IS"
  457.         }
  458.     }
  459.     IF ($UseDefaults -eq "NO")
  460.     {
  461.         ##SSMS,ADV_SSMS
  462.         $Yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes","Selecting yes you will command this installation to install SQL Server Management Studio basic and advanced as one of its features. NOTE: If SSMS is already installed for this cluster then the installation will throw errors."
  463.         $No = New-Object System.Management.Automation.Host.ChoiceDescription "&No","Selecting no you will command this installation to omit SQL Server Management Studio from the feature set."
  464.         $choices = [System.Management.Automation.Host.ChoiceDescription[]]($Yes,$No)
  465.         $caption = "Question!"
  466.         $message = "Would you like to have SQL SERVER MANAGEMENT STUDIO installed?"
  467.         $FeatureChoice = $Host.UI.PromptForChoice($caption,$message,$choices,0)
  468.  
  469.         if ($FeatureChoice -eq 0)
  470.         {
  471.             $Features = $Features + ",SSMS,ADV_SSMS"
  472.         }
  473.     }
  474.     else
  475.     {
  476.         if (($EnvironmentSelection -eq "DEV") -OR ($EnvironmentSelection -eq "SIT"))
  477.         {
  478.             $Features = $Features + ",SSMS,ADV_SSMS"
  479.         }
  480.     }
  481.     IF ($UseDefaults -eq "NO")
  482.     {
  483.         ##CONN,BC,SDK,BOL,SNAC_SDK,OCS
  484.         $Yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes","Selecting yes you will command this installation to install Client Connectivity Tools, Books Online, and SDKs as one of its features. NOTE: If these are already installed for this cluster then the installation will throw errors."
  485.         $No = New-Object System.Management.Automation.Host.ChoiceDescription "&No","Selecting no you will command this installation to omit SQL Server Management Studio from the feature set."
  486.         $choices = [System.Management.Automation.Host.ChoiceDescription[]]($Yes,$No)
  487.         $caption = "Question!"
  488.         $message = "Would you like to have CLIENT CONNECTIVITY TOOLS, BOOKS ONLINE, AND SDKs installed?"
  489.         $FeatureChoice = $Host.UI.PromptForChoice($caption,$message,$choices,0)
  490.  
  491.         if ($FeatureChoice -eq 0)
  492.         {
  493.             $Features = $Features + ",CONN,BC,SDK,BOL,SNAC_SDK,OCS"
  494.         }
  495.     }
  496.     else
  497.     {
  498.         if (($EnvironmentSelection -eq "DEV") -OR ($EnvironmentSelection -eq "SIT"))
  499.         {
  500.             $Features = $Features + ",CONN,BC,SDK,BOL,SNAC_SDK,OCS"
  501.         }
  502.     }
  503.  
  504.     #WRITE FEATURES
  505.     $Features |  Out-File $file -Append
  506. }
  507.  
  508. function SetSysAdminAccounts([string]$UseDefaults, $InstallType)
  509. {
  510.     IF ($UseDefaults -eq "NO")
  511.     {
  512.         #SET SYSADMIN ACCOUNT HERE
  513.         $AcctList = (read-host "Enter a comma delimited list of sysadmin accounts for this instance
  514.         eg DOMAIN\DomainUser, DOMAIN\UserFromDomain").split(",")
  515.  
  516.         $AcctsComplete = [string]""
  517.         foreach ($Acct in $AcctList)
  518.             {
  519.             $Acct = $Acct.Trim()
  520.              $Acct = "`"$Acct`" "
  521.              $AcctsComplete += $Acct
  522.         }
  523.        
  524.         "SQLSYSADMINACCOUNTS=$AcctsComplete" |  Out-File $file -Append
  525.        
  526.         #Choose Security Mode
  527.         $Yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes","Selecting yes you will enable mixed mode authentication which allows for Windows or SQL Authentication. NOTE: This is not a best practice."
  528.         $No = New-Object System.Management.Automation.Host.ChoiceDescription "&No","Selecting no you will restrict your installation to Windows Authentication. NOTE: This option is best practice."
  529.         $choices = [System.Management.Automation.Host.ChoiceDescription[]]($Yes,$No)
  530.         $caption = "Question!"
  531.         $message = "Would you like to use Mixed Mode Authentication (not recommended)?"
  532.         $SecChoice = $Host.UI.PromptForChoice($caption,$message,$choices,1)
  533.        
  534.         switch ($SecChoice)
  535.         {
  536.             0 { $Script:SecChoice="YES" }
  537.             1 { $Script:SecChoice="NO" }
  538.         }
  539.        
  540.         IF ($SecChoice -eq "YES")
  541.         {
  542.             "SECURITYMODE=`"SQL`"" | Out-File $file -Append
  543.         }
  544.     }
  545.     ELSE
  546.     {
  547.         #SET SYSADMIN ACCOUNT HERE
  548.         $AcctList = "DOMAIN\DomainUser, DOMAIN\UserFromDomain".split(",")
  549.  
  550.         $AcctsComplete = [string]""
  551.         foreach ($Acct in $AcctList)
  552.             {
  553.             $Acct = $Acct.Trim()
  554.              $Acct = "`"$Acct`" "
  555.              $AcctsComplete += $Acct
  556.         }
  557.        
  558.         "SQLSYSADMINACCOUNTS=$AcctsComplete" |  Out-File $file -Append
  559.     }
  560.    
  561.     if ($InstallType -eq "STANDALONEINSTALL" )
  562.     {
  563.         #don't add the current user as a sysadmin to the instance
  564.         "ADDCURRENTUSERASSQLADMIN=`"False`"" |  Out-File $file -Append
  565.     }
  566. }
  567.  
  568. #Set service accounts
  569. function SetServiceAccounts([string]$UseDefaults,[string]$Env,[string]$InstallType)
  570. {
  571.     $Script:Env1 = $Env
  572.     $Script:Install1 = $InstallType
  573.     $Script:Default1 = $UseDefaults
  574.  
  575.     IF ($UseDefaults -eq "NO")
  576.     {
  577.         #Choose service accounts
  578.         $Script:SQLServiceAccount = Read-Host "Enter the SQL Service account to be used"
  579.         "SQLSVCACCOUNT=`"$SQLServiceAccount`"" |  Out-File $file -Append
  580.         $Script:SQLAgentAccount = Read-Host "Enter the SQL Agent account to be used"
  581.         "AGTSVCACCOUNT=`"$SQLAgentAccount`"" |  Out-File $file -Append
  582.     }
  583.     ELSE
  584.     {
  585.         switch ($Env)
  586.         {
  587.             "DEV"
  588.             {
  589.                 $Script:SQLServiceAccount = 'DOMAIN\DevSQLService'
  590.                 "SQLSVCACCOUNT=`"$SQLServiceAccount`"" |  Out-File $file -Append
  591.                 $Script:SQLAgentAccount = 'DOMAIN\DevSQLAgent'
  592.                 "AGTSVCACCOUNT=`"$SQLAgentAccount`"" |  Out-File $file -Append
  593.             }
  594.             "SIT"
  595.             {
  596.                 $Script:SQLServiceAccount = 'DOMAIN\SITSQLService'
  597.                 "SQLSVCACCOUNT=`"$SQLServiceAccount`"" |  Out-File $file -Append
  598.                 $Script:SQLAgentAccount = 'DOMAIN\SITSQLAgent'
  599.                 "AGTSVCACCOUNT=`"$SQLAgentAccount`"" |  Out-File $file -Append
  600.             }
  601.             "QA"
  602.             {
  603.                 $Script:SQLServiceAccount = 'DOMAIN\QASQLService'
  604.                 "SQLSVCACCOUNT=`"$SQLServiceAccount`"" |  Out-File $file -Append
  605.                 $Script:SQLAgentAccount = 'DOMAIN\QASQLAgent'
  606.                 "AGTSVCACCOUNT=`"$SQLAgentAccount`"" |  Out-File $file -Append
  607.             }
  608.             "PRODUCTION"
  609.             {
  610.                 $Script:SQLServiceAccount = 'DOMAIN\SQLService'
  611.                 "SQLSVCACCOUNT=`"$SQLServiceAccount`"" |  Out-File $file -Append
  612.                 $Script:SQLAgentAccount = 'DOMAIN\SQLAgent'
  613.                 "AGTSVCACCOUNT=`"$SQLAgentAccount`"" |  Out-File $file -Append
  614.             }
  615.         }
  616.     }
  617. }
  618.  
  619. function SetFileDirectories()
  620. {
  621.     #System databases
  622.     $SysDBfolder = Read-Host "Select root folder for SQL SYSTEM databases (Do not include the trailing '\')
  623.     eg. J: or J:\SQLServer"
  624.     #$SysDBfolder = $object.BrowseForFolder(0, "Select root folder for SQL SYSTEM databases.", 0)
  625.     if ($SysDBfolder -ne $null) {
  626.     #$SysDB = $SysDBfolder.self.Path + "\SQLSystem"
  627.     $SysDB = $SysDBfolder + "\MSSQL10_50." + $SQLInstanceName + "\SQLSystem"
  628.     "INSTALLSQLDATADIR=`"$SysDB`"" |  Out-File $file -Append
  629.     }
  630.  
  631.     #Default User DB location
  632.     $UserDBfolder = Read-Host "Select root folder for USER DATABASE DATA files (Do not include the trailing '\')
  633.     eg. J: or J:\SQLServer"
  634.     #$UserDBfolder = $object.BrowseForFolder(0, "Select root folder for USER DATABASE DATA files.", 0)
  635.     if ($UserDBfolder -ne $null) {
  636.     #$UserDB = $UserDBfolder.self.Path + "\MSSQL\Data"
  637.     $UserDB = $UserDBfolder + "\MSSQL10_50." + $SQLInstanceName + "\MSSQL\Data"
  638.     "SQLUSERDBDIR=`"$UserDB`"" |  Out-File $file -Append
  639.     }
  640.  
  641.     #Default User Log location
  642.     $UserLogfolder = Read-Host "Select root folder for USER DATABASE LOG files (Do not include the trailing '\')
  643.     eg. J: or J:\SQLServer"
  644.     #$UserLogfolder = $object.BrowseForFolder(0, "Select root folder for USER DATABASE LOG files", 0)
  645.     if ($UserLogfolder -ne $null) {
  646.     #$UserLog = $UserLogfolder.self.Path + "\MSSQL\Logs"
  647.     $UserLog = $UserLogfolder + "\MSSQL10_50." + $SQLInstanceName + "\MSSQL\Logs"
  648.     "SQLUSERDBLOGDIR=`"$UserLog`"" |  Out-File $file -Append
  649.     }
  650.    
  651.     #TempDB
  652.     $TempDBfolder = Read-Host "Select root folder for SQL TempDB (Do not include the trailing '\')
  653.     eg. J: or J:\SQLServer"
  654.     #$TempDBfolder = $object.BrowseForFolder(0, "Select root folder for SQL TempDB.", 0)
  655.     if ($TempDBfolder -ne $null) {
  656.     #$TempDB = $TempDBfolder.self.Path + "\MSSQL\Data"
  657.     $TempDB = $TempDBfolder + "\MSSQL10_50." + $SQLInstanceName + "\MSSQL\Data"
  658.     "SQLTEMPDBDIR=`"$TempDB`"" |  Out-File $file -Append
  659.     }
  660.  
  661.     #Default backup location
  662.     $Backupfolder = Read-Host "Select ROOT folder for DATABASE BACKUPS (Do not include the trailing '\')
  663.     eg. J: or J:\SQLServer"
  664.     #$Backupfolder = $object.BrowseForFolder(0, "Select root folder for DATABASE BACKUPS", 0)
  665.     if ($Backupfolder -ne $null) {
  666.     #$Backup = $Backupfolder.self.Path + "\MSSQL\Backup"
  667.     $Backup = $Backupfolder + "\MSSQL10_50." + $SQLInstanceName + "\MSSQL\Backup"
  668.     "SQLBACKUPDIR=`"$Backup`"" |  Out-File $file -Append
  669.     }
  670. }
  671.  
  672. function SetClusterDisks()
  673. {
  674.     $DiskList = (read-host "Enter a comma delimited list of failover cluster disks for use in this cluster
  675.     eg SQL Data, SQL Log, SQL Backup").split(",")
  676.  
  677.     $DiskComplete = [string]""
  678.     foreach ($Disk in $DiskList)
  679.         {
  680.         $Disk = $Disk.Trim()
  681.          $Disk = "`"$Disk`" "
  682.          $DiskComplete += $Disk
  683.     }
  684.  
  685.     "FAILOVERCLUSTERDISKS=$DiskComplete" |  Out-File $file -Append
  686. }
  687.  
  688. #Let the use know the script is complete and where the files reside    
  689. function ExitMessage([string]$SkipMessage,[string]$InstallType)
  690. {
  691.     if($SkipMessage -eq "NO")
  692.     {
  693.         switch ( $InstallChoice )
  694.         {
  695.             "STANDALONEINSTALL"
  696.             {
  697.                 [system.Windows.Forms.MessageBox]::show
  698.                 (
  699.                     "SQL ini file created!
  700.                         Be sure to check your ini config before using.
  701.                            
  702.                     To create a new SQL instance use:
  703.                         `"$file`"
  704.                        
  705.                     Example:
  706.                         setup.exe /CONFIGURATIONFILE=`"<Filename.ini>`"
  707.                         /SQLSVCPASSWORD=`"<SQL service account pwd>`"
  708.                         /AGTSVCPASSWORD=`"<Agent service account pwd>`"
  709.                        
  710.                     Setup command written to PowerShell output window.    
  711.                 ")
  712.             }
  713.             "INSTALLCLUSTER"
  714.             {
  715.                 [system.Windows.Forms.MessageBox]::show
  716.                 (
  717.                     "SQL ini files created!
  718.                         Be sure to check your ini config before using.
  719.                            
  720.                     To create a new clustered SQL instance use:
  721.                         `"$file`"
  722.                        
  723.                     To add a node to an existing cluster use:  
  724.                         `"$FileNameAddNode`"
  725.                            
  726.                     Example:
  727.                         setup.exe /CONFIGURATIONFILE=`"<Filename.ini>`"
  728.                         /SQLSVCPASSWORD=`"<SQL service account pwd>`"
  729.                         /AGTSVCPASSWORD=`"<Agent service account pwd>`"
  730.                        
  731.                     Setup command written to PowerShell output window.    
  732.                 ")
  733.             }
  734.             "ADDNODE"
  735.             {
  736.                 [system.Windows.Forms.MessageBox]::show
  737.                 (
  738.                     "SQL ini files created!
  739.                         Be sure to check your ini config before using.
  740.                        
  741.                     To add a node to an existing cluster use:  
  742.                         `"$FileNameAddNode`"
  743.                            
  744.                     Example:
  745.                         setup.exe /CONFIGURATIONFILE=`"<Filename.ini>`"
  746.                         /SQLSVCPASSWORD=`"<SQL service account pwd>`"
  747.                         /AGTSVCPASSWORD=`"<Agent service account pwd>`"
  748.                        
  749.                     Setup command written to PowerShell output window.    
  750.                 ")
  751.             }
  752.             default
  753.             {
  754.                 Write-Error "Installation choice not recognized."
  755.             }
  756.         }
  757.     }
  758. }
  759.  
  760. #Write everything to the AddNode ini file
  761. function WriteAddNodeFile()
  762. {
  763.     ";File created by: $FileCreator" | Out-File $FileNameAddNode
  764.     ";File creation date: $CurrDate" | Out-File $FileNameAddNode -Append
  765.  
  766.     ";Script to add node to existing SQL cluster" | Out-file $FileNameAddNode -Append
  767.     ";SQLSERVER2008 Configuration File" | Out-file $FileNameAddNode -Append
  768.     "[SQLSERVER2008]" | Out-File $FileNameAddNode -Append
  769.  
  770.     "IACCEPTSQLSERVERLICENSETERMS=`"TRUE`"" | Out-File $FileNameAddNode -Append
  771.  
  772.     "ACTION=`"AddNode`"" | Out-File $FileNameAddNode -Append
  773.     "HELP=`"False`"" | Out-File $FileNameAddNode -Append
  774.     "INDICATEPROGRESS=`"True`"" | Out-File $FileNameAddNode -Append
  775.     "QUIET=`"True`"" | Out-File $FileNameAddNode -Append
  776.     "X86=`"False`"" | Out-File $FileNameAddNode -Append
  777.     "ENU=`"True`""  | Out-File $FileNameAddNode -Append
  778.    
  779.     "FTSVCACCOUNT=`"NT AUTHORITY\LOCALSERVICE`"" | Out-File $FileNameAddNode -Append
  780.    
  781.     "SQLSVCACCOUNT=`"$SQLServiceAccount`"" |  Out-File $FileNameAddNode -Append
  782.  
  783.     "AGTSVCACCOUNT=`"$SQLAgentAccount`"" |  Out-File $FileNameAddNode -Append  
  784.    
  785.     "FAILOVERCLUSTERNETWORKNAME=`"$SQLVirtualName`"" | Out-File $FileNameAddNode -Append
  786.  
  787.     "INSTANCENAME=`"$SQLInstanceName`"" |  Out-File $FileNameAddNode -Append
  788.     "FAILOVERCLUSTERGROUP=`"$SQLVirtualName`"" |  Out-File $FileNameAddNode -Append
  789. }
  790.  
  791. function ExecuteInstall([string]$SQLAuthMode)
  792. {
  793.     IF ($SQLAuthMode -eq "NO")
  794.     {
  795.         $SQLSVCPASSWORD = read-host "/SQLSVCPASSWORD"
  796.         $AGTSVCPASSWORD = read-host "/AGTSVCPASSWORD"
  797.        
  798.         $SetupFilePath = read-host "setup.exe fully qualified file path (ie. D:\)"
  799.         $ExecCmd = $SetupFilePath + 'setup.exe'
  800.         $ExecCmd = $ExecCmd + " /CONFIGURATIONFILE=`"$file`" /SQLSVCPASSWORD=`"$SQLSVCPASSWORD`" /AGTSVCPASSWORD=`"$AGTSVCPASSWORD`""
  801.        
  802.         Invoke-Item $ExecCmd
  803.     }
  804.     ELSE
  805.     {
  806.         $SAPWD = read-host "/SAPWD"
  807.         $SQLSVCPASSWORD = read-host "/SQLSVCPASSWORD"
  808.         $AGTSVCPASSWORD = read-host "/AGTSVCPASSWORD"
  809.        
  810.         $SetupFilePath = read-host "setup.exe fully qualified file path (ie. D:\)"
  811.         $ExecCmd = $SetupFilePath + 'setup.exe'
  812.         $ExecCmd = $ExecCmd + "/CONFIGURATIONFILE=`"$file`" /SQLSVCPASSWORD=`"$SQLSVCPASSWORD`" /AGTSVCPASSWORD=`"$AGTSVCPASSWORD`" /SAPWD=`"$SAPWD`""
  813.        
  814.         Invoke-Item $ExecCmd
  815.     }
  816. }
  817.  
  818. function PrintExecCMD([string]$SQLAuthMode)
  819. {
  820.     IF ($SQLAuthMode -eq "NO")
  821.     {
  822.         $ExecCmdPrintOut = "setup.exe /CONFIGURATIONFILE=`"$file`" /SQLSVCPASSWORD=`"<enter pwd>`" /AGTSVCPASSWORD=`"<enter pwd>`""
  823.        
  824.         #export to clipboard
  825.         $ExecCmdPrintOut | Out-Clipboard
  826.        
  827.         Write-Host ""
  828.         Write-Host $ExecCmdPrintOut
  829.         Write-Host ""
  830.         Write-Host "The above command has been outputed to your clipboard."
  831.     }
  832.     ELSE
  833.     {
  834.         $ExecCmdPrintOut = "setup.exe /CONFIGURATIONFILE=`"$file`" /SQLSVCPASSWORD=`"<enter pwd>`" /AGTSVCPASSWORD=`"<enter pwd>`" /SAPWD=`"<enter pwd>`""
  835.        
  836.         #export to clipboard
  837.         $ExecCmdPrintOut | Out-Clipboard
  838.        
  839.         Write-Host ""
  840.         Write-Host $ExecCmdPrintOut
  841.         Write-Host ""
  842.         Write-Host "The above command has been outputed to your clipboard."
  843.     }
  844. }
  845.  
  846. ################
  847. ###   Main  ####
  848. ################
  849.  
  850. #Use defaults is commented out because values would have to be populated specific
  851. #to your company's organizational standards before it can be used.
  852. #If you search the script for $UseDefaults you will find all areas were default code
  853. #is already available. Analyze the values in those default categories and set them to your
  854. #own and then uncomment the UseDefaults function call below and comment out the setting
  855. #of the $DefaultChoice variable
  856.  
  857. #UseDefaults
  858.  
  859. $Script:DefaultChoice = "NO"
  860.  
  861. ###################################
  862.  
  863.  
  864. WelcomeMessage $DefaultChoice
  865.    
  866. SelectEnvironment $DefaultChoice
  867.  
  868. SetInstallationType
  869.  
  870. SetFilePath
  871.  
  872. switch ( $InstallChoice )
  873. {
  874.     "STANDALONEINSTALL"
  875.     {
  876.         WriteNonConfigurableOptions $InstallChoice
  877.        
  878.         ConfigureInstanceOptions $InstallChoice
  879.        
  880.         SetFeatures $DefaultChoice
  881.        
  882.         SetSysAdminAccounts $DefaultChoice $InstallChoice
  883.        
  884.         SetServiceAccounts $DefaultChoice $EnvironmentSelection $InstallChoice
  885.        
  886.         SetFileDirectories
  887.        
  888.         ExitMessage $DefaultChoice, $InstallChoice
  889.        
  890.         #Offer an execution right now
  891.         $Yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes","By selecting yes this script will compile an executable command and begin the installation immediately."
  892.         $No = New-Object System.Management.Automation.Host.ChoiceDescription "&No","By selecting no this script will compile and display a rough executable command for you along with copying the command to your clipboard for manual execution."
  893.         $choices = [System.Management.Automation.Host.ChoiceDescription[]]($Yes,$No)
  894.         $caption = "Question!"
  895.         $message = "Would you like to enter passwords and run this installation now?"
  896.         $ExecuteChoice = $Host.UI.PromptForChoice($caption,$message,$choices,1)
  897.            
  898.         switch ($ExecuteChoice)
  899.         {
  900.             0 {$ExecuteChoice = "YES"}
  901.             1 {$ExecuteChoice = "NO"}
  902.         }
  903.        
  904.         if ($ExecuteChoice -eq "YES")
  905.         {
  906.             #ExecuteInstall $SecChoice
  907.            
  908.             "There is currently a bug preventing execution so I'm forcing you to print not execute."
  909.             PrintExecCMD $SecChoice
  910.         }
  911.         ELSE
  912.         {
  913.             PrintExecCMD $SecChoice
  914.         }
  915.     }
  916.     "INSTALLCLUSTER"
  917.     {
  918.         Try
  919.         {
  920.             WriteNonConfigurableOptions $InstallChoice
  921.            
  922.             ConfigureInstanceOptions $InstallChoice
  923.            
  924.             SetFeatures $DefaultChoice
  925.            
  926.             SetSysAdminAccounts $DefaultChoice $InstallChoice
  927.            
  928.             SetServiceAccounts $DefaultChoice $EnvironmentSelection $InstallChoice
  929.  
  930.             SetFileDirectories
  931.  
  932.             SetClusterDisks
  933.  
  934.             WriteAddNodeFile
  935.  
  936.             ExitMessage $DefaultChoice, $InstallChoice
  937.            
  938.             #Offer an execution right now
  939.             $Yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes","By selecting yes this script will compile an executable command and begin the installation immediately."
  940.             $No = New-Object System.Management.Automation.Host.ChoiceDescription "&No","By selecting no this script will compile and display a rough executable command for you along with copying the command to your clipboard for manual execution."
  941.             $choices = [System.Management.Automation.Host.ChoiceDescription[]]($Yes,$No)
  942.             $caption = "Question!"
  943.             $message = "Would you like to enter passwords and run this installation now?"
  944.             $ExecuteChoice = $Host.UI.PromptForChoice($caption,$message,$choices,1)
  945.                
  946.             switch ($ExecuteChoice)
  947.             {
  948.                 0 {$ExecuteChoice = "YES"}
  949.                 1 {$ExecuteChoice = "NO"}
  950.             }
  951.                
  952.             if ($ExecuteChoice -eq "YES")
  953.             {
  954.                 ExecuteInstall $SecChoice
  955.             }
  956.             ELSE
  957.             {
  958.                 PrintExecCMD $SecChoice
  959.             }
  960.         }
  961.         Catch
  962.         {
  963.             Write-Error "Errors occured during the INI creation. Inspect your INI file before attempting to use it."
  964.         }
  965.     }
  966.     "ADDNODE"
  967.     {
  968.         Try
  969.         {      
  970.             WriteNonConfigurableOptions $InstallChoice
  971.            
  972.             ConfigureInstanceOptions $InstallChoice
  973.            
  974.             SetServiceAccounts $DefaultChoice $EnvironmentSelection $InstallChoice
  975.  
  976.             ExitMessage $DefaultChoice $InstallChoice
  977.         }
  978.         Catch
  979.         {
  980.             Write-Error "Errors occured during the INI creation. Inspect your INI file before attempting to use it."
  981.         }  
  982.     }
  983.     default
  984.     {
  985.         Write-Error "Installation choice not recognized."
  986.     }
  987. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement