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

$ErrorActionPreference = "Stop"

$prefix = $SAFConfiguration.prefix
$license = $SAFConfiguration.license
$sqlServer = $SAFConfiguration.sql.serverName
$sqlUser = $SAFConfiguration.sql.adminUsername
$sqlAdminPassword = $SAFConfiguration.sql.adminPassword
$sqlSitecorePassword = $SAFConfiguration.sql.sitecorePassword
$sitecoreAdminUserPassword = $SAFConfiguration.sitecore.adminPassword
$identityServerUrl = "https://$($SAFConfiguration.identityServer.hostName)"
$identityServerSecret = $SAFConfiguration.identityServer.clientSecret
$telerikEncryptionKey = $SAFConfiguration.telerikEncryptionKey
$package = Get-ChildItem -Path "$SAFInstallPackageDir\*" -Include *cm.scwdp.zip*
$sifConfiguration = "$PSScriptRoot\sitecore-XM0.json"

$serverCert = BuildSitecoreServerCertName -Prefix $prefix
$hostNames = $SAFConfiguration.sitecore.hostNames
$siteName = $hostNames[0]
$installDir = $SAFConfiguration.sitecore.installDir
   
Write-Output "Install Sitecore started..."

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

$sitecoreParams = @{
    Path                      = $sifConfiguration
    Package                   = $package.FullName
    LicenseFile               = $license
    SqlDbPrefix               = $prefix
    SolrCorePrefix            = $prefix
    SSLCert                   = $serverCert
    Sitename                  = $siteName
    SitecoreAdminPassword     = $sitecoreAdminUserPassword
    SqlAdminUser              = $sqlUser
    SqlAdminPassword          = $sqlAdminPassword
    SqlSecurityUser           = "$($prefix)_securityuser"
    SqlSecurityPassword       = $sqlSitecorePassword
    SqlCoreUser               = "$($prefix)_coreuser"
    SqlCorePassword           = $sqlSitecorePassword
    SqlMasterUser             = "$($prefix)_masteruser"
    SqlMasterPassword         = $sqlSitecorePassword
    SqlWebUser                = "$($prefix)_webuser"
    SqlWebPassword            = $sqlSitecorePassword
    SqlFormsUser              = "$($prefix)_formsuser"
    SqlFormsPassword          = $sqlSitecorePassword
    SqlServer                 = $sqlServer
    SolrUrl                   = $SAFSolrServiceURL
    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."