Pipelines/Steps/Install/OnPrem/Sitecore/XP/Scaled/9.0/Install-CD.ps1

$ErrorActionPreference = "Stop"

$prefix = $SAFConfiguration.prefix
$license = $SAFConfiguration.license
$sqlServer = $SAFConfiguration.sql.serverName
$sqlSitecorePassword = $SAFConfiguration.sql.sitecorePassword
$solrURL = $SAFSolrServiceURL
$xConnectCollectionService = $SAFConfiguration.xConnect.collectionServiceURL
$xConnectReferenceDataService = $SAFConfiguration.xDB.referenceDataServiceURL
$marketingAutomationOperationsService = $SAFConfiguration.xDB.automationOperationsServiceURL
$marketingAutomationReportingService = $SAFConfiguration.xDB.automationReportingServiceURL
$exmCryptographicKey = $SAFConfiguration.exm.cryptographicKey
$exmAuthenticationKey = $SAFConfiguration.exm.authenticationKey
$package = Get-ChildItem -Path "$SAFInstallPackageDir\*" -Include *cd.scwdp.zip*
$sifConfiguration = GetSIFConfiguration -Name "sitecore-XP1-cd.json" -ContextPath "$PSScriptRoot"

$clientCert = BuildSitecoreClientCertName -Prefix $prefix
$serverCert = BuildSitecoreServerCertName -Prefix $prefix

$hostNames = $SAFConfiguration.sitecore.hostNames
$siteName = $hostNames[0]
$installDir = $SAFConfiguration.sitecore.installDir

Write-Output "Install Sitecore CD started..."

$sitecoreParams = @{
    Path                                 = $sifConfiguration
    Package                              = $package.FullName
    LicenseFile                          = $license
    SqlDbPrefix                          = $prefix
    SqlServer                            = $sqlServer
    SqlCoreUser                          = "$($prefix)_coreuser"
    SqlCorePassword                      = $sqlSitecorePassword
    SqlWebUser                           = "$($prefix)_webuser"
    SqlWebPassword                       = $sqlSitecorePassword
    SqlFormsUser                         = "$($prefix)_formsuser"
    SqlFormsPassword                     = $sqlSitecorePassword
    SqlExmMasterUser                     = "$($prefix)_exmmasteruser"
    SqlExmMasterPassword                 = $sqlSitecorePassword
    SqlMessagingUser                     = "$($prefix)_messaginguser"
    SqlMessagingPassword                 = $sqlSitecorePassword
    SolrCorePrefix                       = $prefix
    SolrUrl                              = $solrURL
    Sitename                             = $siteName
    XConnectCert                         = $clientCert
    XConnectCollectionService            = $xConnectCollectionService
    XConnectReferenceDataService         = $xConnectReferenceDataService
    MarketingAutomationOperationsService = $marketingAutomationOperationsService
    MarketingAutomationReportingService  = $marketingAutomationReportingService
    EXMCryptographicKey                  = $exmCryptographicKey
    EXMAuthenticationKey                 = $exmAuthenticationKey
    InstallDirectory                     = $installDir
}
Install-SitecoreConfiguration @sitecoreParams
AddWebBindings -SiteName $siteName -HostNames $hostNames
AddWebBindings -SiteName $siteName -HostNames $hostNames -SSLCert $serverCert
Write-Output "Install Sitecore CD done."