[CmdletBinding()] param( [Parameter(Mandatory=$true)] [string] $ExchangeServerVersion ) try { Start-Transcript -Path C:\cfn\log\Install-ExchPrerequisites.ps1.txt -Append $ErrorActionPreference = "Stop" $Retries = 0 $Installed = $false do { try { if($ExchangeServerVersion -eq "2016") { Install-WindowsFeature Server-Media-Foundation Install-WindowsFeature NET-Framework-45-Features, RPC-over-HTTP-proxy, RSAT-Clustering, RSAT-Clustering-CmdInterface, RSAT-Clustering-Mgmt, RSAT-Clustering-PowerShell, Web-Mgmt-Console, WAS-Process-Model, Web-Asp-Net45, Web-Basic-Auth, Web-Client-Auth, Web-Digest-Auth, Web-Dir-Browsing, Web-Dyn-Compression, Web-Http-Errors, Web-Http-Logging, Web-Http-Redirect, Web-Http-Tracing, Web-ISAPI-Ext, Web-ISAPI-Filter, Web-Lgcy-Mgmt-Console, Web-Metabase, Web-Mgmt-Console, Web-Mgmt-Service, Web-Net-Ext45, Web-Request-Monitor, Web-Server, Web-Stat-Compression, Web-Static-Content, Web-Windows-Auth, Web-WMI, Windows-Identity-Foundation, RSAT-ADDS -Restart -ErrorAction Stop $Installed = $true } elseif ($ExchangeServerVersion -eq "2019") { Install-WindowsFeature Server-Media-Foundation Install-WindowsFeature NET-Framework-45-Features, RPC-over-HTTP-proxy, RSAT-Clustering, RSAT-Clustering-CmdInterface, RSAT-Clustering-PowerShell, WAS-Process-Model, Web-Asp-Net45, Web-Basic-Auth, Web-Client-Auth, Web-Digest-Auth, Web-Dir-Browsing, Web-Dyn-Compression, Web-Http-Errors, Web-Http-Logging, Web-Http-Redirect, Web-Http-Tracing, Web-ISAPI-Ext, Web-ISAPI-Filter, Web-Metabase, Web-Mgmt-Service, Web-Net-Ext45, Web-Request-Monitor, Web-Server, Web-Stat-Compression, Web-Static-Content, Web-Windows-Auth, Web-WMI, RSAT-ADDS -Restart -ErrorAction Stop $Installed = $true } } catch { $exception = $_ $retries++ if ($retries -lt 6) { Write-Host $exception $linearBackoff = $retries * 60 Write-Host "Prerequisites installation failed. Retrying in $linearBackoff seconds." Start-Sleep -Seconds $linearBackoff } } } while (($retries -lt 6) -and (-not $installed)) if (-not $installed) { throw $exception } } catch { $_ | Write-AWSQuickStartException }