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

$ErrorActionPreference = "Stop"

$prefix = $SAFConfiguration.prefix
$hostNames = $SAFConfiguration.sitecore.hostNames
$siteName = $hostNames[0]
$installDir = $SAFConfiguration.sitecore.installDir
$license = $SAFConfiguration.license
$sqlServer = $SAFConfiguration.sql.serverName
$sqlUser = $SAFConfiguration.sql.adminUsername
$sqlAdminPassword = $SAFConfiguration.sql.adminPassword
$sqlSitecorePassword = $SAFConfiguration.sql.sitecorePassword
$solrURL = $SAFSolrServiceURL
$package = Get-ChildItem -Path "$SAFInstallPackageDir\*" -Include *single.scwdp.zip*
$sifConfiguration = "$PSScriptRoot\sitecore-XM0.json"

$serverCert = BuildSitecoreServerCertName -Prefix $prefix

$sitecoreParams = @{
    Path                = $sifConfiguration
    Package             = $package
    LicenseFile         = $license
    SiteName            = $siteName
    SqlServer           = $sqlServer
    SqlAdminUser        = $sqlUser
    SqlAdminPassword    = $sqlAdminPassword
    SqlDbPrefix         = $prefix
    SqlCoreUser         = "$($prefix)_coreuser"
    SqlCorePassword     = $sqlSitecorePassword
    SqlMasterUser       = "$($prefix)_masteruser"
    SqlMasterPassword   = $sqlSitecorePassword
    SqlWebUser          = "$($prefix)_webuser"
    SqlWebPassword      = $sqlSitecorePassword
    SqlFormsUser        = "$($prefix)_formsuser"
    SqlFormsPassword    = $sqlSitecorePassword
    SSLCert             = $serverCert
    SolrCorePrefix      = $prefix
    SolrUrl             = $solrURL
    InstallDirectory    = $installDir
}

$dbs = @("$($prefix)_Core", "$($prefix)_Master", "$($prefix)_Web", "$($prefix)_ExperienceForms")
DeleteDatabases -SqlServer $sqlServer -Databases $dbs -Username $sqlUser -Password $sqlAdminPassword
Install-SitecoreConfiguration @sitecoreParams
AddWebBindings -SiteName $siteName -HostNames $hostNames
AddWebBindings -SiteName $siteName -HostNames $hostNames -SSLCert $serverCert