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

$ErrorActionPreference = "Stop"

$prefix = $SAFConfiguration.prefix
$license = $SAFConfiguration.license
$sqlServer = $SAFConfiguration.sql.serverName
$sqlSitecorePassword = $SAFConfiguration.sql.sitecorePassword
$solrURL = $SAFSolrServiceURL
$identityServerUrl = "https://$($SAFConfiguration.identityServer.hostName)"
$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
    SolrCorePrefix = $prefix
    XConnectCert = $clientCert
    Sitename = $siteName
    SqlSecurityUser = "$($prefix)_securityuser"
    SqlSecurityPassword = $sqlSitecorePassword
    SqlWebUser = "$($prefix)_webuser"
    SqlWebPassword = $sqlSitecorePassword
    SqlFormsUser = "$($prefix)_formsuser"
    SqlFormsPassword = $sqlSitecorePassword
    SqlExmMasterUser = "$($prefix)_exmmasteruser"
    SqlExmMasterPassword = $sqlSitecorePassword
    SqlMessagingUser = "$($prefix)_messaginguser"
    SqlMessagingPassword = $sqlSitecorePassword
    SqlServer = $sqlServer
    SolrUrl = $solrURL
    XConnectCollectionService = $xConnectCollectionService
    XConnectReferenceDataService = $xConnectReferenceDataService
    MarketingAutomationOperationsService = $marketingAutomationOperationsService
    MarketingAutomationReportingService = $marketingAutomationReportingService
    SitecoreIdentityAuthority = $identityServerUrl
    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."