Pipelines/Steps/Install/OnPrem/Sitecore/XP/Scaled/9.1/Install-REP.ps1

$ErrorActionPreference = "Stop"

$prefix = $SAFConfiguration.prefix
$siteName = $SAFConfiguration.reporting.hostName
$hostNames = @($siteName)
$license = $SAFConfiguration.license
$sqlServer = $SAFConfiguration.sql.serverName
$sqlSitecorePassword = $SAFConfiguration.sql.sitecorePassword
$installDir = $SAFConfiguration.reporting.installDir
$serviceApiKey = $SAFConfiguration.reporting.serviceApiKey
$package = Get-ChildItem -Path "$SAFInstallPackageDir\*" -Include *rep.scwdp.zip*
$sifConfiguration = GetSIFConfiguration -Name "sitecore-XP1-rep.json" -ContextPath "$PSScriptRoot"

$serverCert = BuildSitecoreServerCertName -Prefix $prefix

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

$sitecoreParams = @{
    Path = $sifConfiguration
    Package = $package.FullName
    LicenseFile = $license
    SSLCert = $serverCert
    SqlDbPrefix = $prefix
    Sitename = $siteName
    SqlCoreUser = "$($prefix)_coreuser"
    SqlCorePassword = $sqlSitecorePassword
    SqlSecurityUser = "$($prefix)_securityuser"
    SqlSecurityPassword = $sqlSitecorePassword
    SqlMasterUser = "$($prefix)_masteruser"
    SqlMasterPassword = $sqlSitecorePassword
    SqlReportingUser = "$($prefix)_reportinguser"
    SqlReportingPassword = $sqlSitecorePassword
    SqlServer = $sqlServer
    ReportingServiceApiKey = $serviceApiKey 
    InstallDirectory = $installDir
}
Install-SitecoreConfiguration @sitecoreParams
AddWebBindings -SiteName $siteName -HostNames $hostNames
AddWebBindings -SiteName $siteName -HostNames $hostNames -SSLCert $serverCert

Write-Output "Install Sitecore Reporting done."