param(
    [string]$siteName = "react-iAdmin",
    [string]$physicalPath = "C:\inetpub\wwwroot\react-iAdmin",
    [string]$hostName,
    [int]$port = 80
)

# Install IIS roles and features
Write-Host "Installing required IIS roles and features..."
Install-WindowsFeature -ConfigurationFilePath ".\DeploymentConfigTemplate.xml"

Import-Module WebAdministration

# Create IIS site
Write-Host "Checking for existing $siteName site..."
if (Get-Website -Name $siteName -ErrorAction SilentlyContinue) {
    Write-Host "Removing existing $siteName site..."
    Remove-Website -Name $siteName
}
New-Website -Name $siteName -PhysicalPath $physicalPath -HostHeader $hostName -Port $port -Force
Start-Website -Name $siteName