Pipelines/Steps/Install/OnPrem/Sitecore/XP/AllInOne/9.2/Install-Sitecore.ps1

$ErrorActionPreference = "Stop"

Write-Output "Install Sitecore started..."

$prefix = $SAFConfiguration.prefix
$license = $SAFConfiguration.license
$hostNames = $SAFConfiguration.sitecore.hostNames
$siteName = $hostNames[0]
$xConnectUrl = "https://$($SAFConfiguration.xConnect.hostName)"
$sqlServer = $SAFConfiguration.sql.serverName
$sqlUser =  $SAFConfiguration.sql.adminUsername
$sqlAdminPassword =  $SAFConfiguration.sql.adminPassword
$sqlSitecorePassword = $SAFConfiguration.sql.sitecorePassword
$installDir = $SAFConfiguration.sitecore.installDir
$sitecoreAdminUserPassword = $SAFConfiguration.sitecore.adminPassword
$identityServerUrl = "https://$($SAFConfiguration.identityServer.hostName)"
$identityServerSecret = $SAFConfiguration.identityServer.clientSecret
$edsProvider = "CustomSMTP"
if (![string]::IsNullOrEmpty($SAFConfiguration.exm.edsProviderURL)) {
    $edsProvider = $SAFConfiguration.exm.edsProviderURL
}

$cryptographicKey = $SAFConfiguration.exm.cryptographicKey
$authenticationKey = $SAFConfiguration.exm.authenticationKey
$telerikEncryptionKey = $SAFConfiguration.telerikEncryptionKey

$package = Get-ChildItem -Path "$SAFInstallPackageDir\*" -Include *single.scwdp.zip*
$sifConfiguration = GetSIFConfiguration -Name "sitecore-XP0.json" -ContextPath "$PSScriptRoot"

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

$dbs = @("$($prefix)_Core", "$($prefix)_EXM.Master", "$($prefix)_ExperienceForms", "$($prefix)_Master", "$($prefix)_Processing.Tasks", "$($prefix)_Web")
DeleteDatabases -SqlServer $sqlServer -Databases $dbs -Username $sqlUser -Password $sqlAdminPassword

$sitecoreParams = @{
    Path = $sifConfiguration
    Package = $package.FullName
    LicenseFile = $license
    SqlDbPrefix = $prefix
    SolrCorePrefix = $prefix
    XConnectCert = $clientCert
    Sitename = $siteName
    SitecoreAdminPassword = $sitecoreAdminUserPassword
    SqlAdminUser = $sqlUser
    SqlAdminPassword = $sqlAdminPassword
    SqlCoreUser = "$($prefix)_coreuser"
    SqlCorePassword = $sqlSitecorePassword
    SqlSecurityUser = "$($prefix)_securityuser"
    SqlSecurityPassword = $sqlSitecorePassword
    SqlMasterUser = "$($prefix)_masteruser"
    SqlMasterPassword = $sqlSitecorePassword
    SqlWebUser = "$($prefix)_webuser"
    SqlWebPassword = $sqlSitecorePassword
    SqlReportingUser = "$($prefix)_reportinguser"
    SqlReportingPassword = $sqlSitecorePassword
    SqlProcessingPoolsUser = "$($prefix)_processingpoolsuser"
    SqlProcessingPoolsPassword = $sqlSitecorePassword
    SqlProcessingTasksUser = "$($prefix)_processingtasksuser"
    SqlProcessingTasksPassword = $sqlSitecorePassword
    SqlReferenceDataUser = "$($prefix)_referencedatauser"
    SqlReferenceDataPassword = $sqlSitecorePassword
    SqlMarketingAutomationUser = "$($prefix)_marketingautomationuser"
    SqlMarketingAutomationPassword = $sqlSitecorePassword
    SqlFormsUser = "$($prefix)_formsuser"
    SqlFormsPassword = $sqlSitecorePassword
    SqlExmMasterUser = "$($prefix)_exmmasteruser"
    SqlExmMasterPassword = $sqlSitecorePassword
    SqlMessagingUser = "$($prefix)_messaginguser"
    SqlMessagingPassword = $sqlSitecorePassword
    SqlServer = $sqlServer
    ExmEdsProvider = $edsProvider
    EXMCryptographicKey = $cryptographicKey
    EXMAuthenticationKey = $authenticationKey
    SolrUrl = $SAFSolrServiceURL
    XConnectCollectionService = $xConnectUrl
    SitecoreIdentityAuthority = $identityServerUrl
    SitecoreIdentitySecret = $identityServerSecret
    TelerikEncryptionKey = $telerikEncryptionKey
    InstallDirectory = $installDir
}

Install-SitecoreConfiguration @sitecoreParams
AddWebBindings -SiteName $siteName -HostNames $hostNames
AddWebBindings -SiteName $siteName -HostNames $hostNames -SSLCert $serverCert

Write-Output "Install Sitecore done."