#################################################################################### # Set-Lync2010Windows2008R2Features.ps1 # Configures Windows Features to install Lync Server 2010 # on a Windows Server 2008 R2 Server # # v03 February2011 by Ståle Hansen (http://msunified.net) # # Thanks to # Marjus Sirvinsks (http://marjuss.wordpress.com/) for adapting the script for OCS and Lync # The Script is almost entirely based on Pat Richard, Bhargav Shukla and Anderson Patricio's script designed for Exchange 2010 # check it out here: http://msunified.net/exchange-downloads/script-exchange2010prereqs-ps1/ # #################################################################################### # Detect correct OS here and exit if no match if (-not((Get-WMIObject win32_OperatingSystem).OSArchitecture -eq '64-bit') -and (Get-WMIObject win32_OperatingSystem).Version -eq '6.1.7600'){ Write-Host "`nThis script requires a 64bit version of Windows Server 2008 R2, which this is not. Exiting...`n" -ForegroundColor Red Exit } clear-host pushd [string] $targetfolder = "c:\Install" # [string] $targetfolder = (Get-Content Env:Temp) [bool] $wasinstalled = $false [bool] $RebootRequired = $false # determine if BitsTransfer is already installed if (Get-Module BitsTransfer){$wasinstalled = $true}else{$wasinstalled = $false} # this should probably get moved to a function... if ((Get-Module ServerManager) -eq $null){Import-Module ServerManager} [string] $opt = "None" [bool] $HasInternetAccess = ([Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]'{DCB00C01-570F-4A9B-8D69-199FDBA5723B}')).IsConnectedToInternet) [string] $menu = @' Lync Server 2010 - Prerequisites script Please, select which role you are going to install.. 1) Front-End 2) Director 3) Monitoring/Archiving 4) Communicator Web Access (OCS 2007 R2) 5) Mediation 6) Edge/XMPP GW 7) GroupChat 8) Download and install Lync Server 2010 ResKit 9) Download and install Lync Server 2010 Best Practices Analyzer 10) Exit and reboot 11) Exit '@ function GetIt ([string]$sourcefile) { if ($HasInternetAccess){ # check if BitsTransfer is installed if ((Get-Module BitsTransfer) -eq $null){ Write-Host "BitsTransfer: Installing..." -NoNewLine Import-Module BitsTransfer Write-Host "`b`b`b`b`b`b`b`b`b`b`b`b`binstalled! " -ForegroundColor Green } [string] $targetfile = $sourcefile.Substring($sourcefile.LastIndexOf("/") + 1) if (Test-Path $targetfolder){ Write-Host "Folder: $targetfolder exists." } else{ Write-Host "Folder: $targetfolder does not exist, creating..." -NoNewline New-Item $targetfolder -type Directory | Out-Null Write-Host "`b`b`b`b`b`b`b`b`b`b`bcreated! " -ForegroundColor Green } if (Test-Path "$targetfolder\$targetfile"){ Write-Host "File: $targetfile exists." }else{ Write-Host "File: $targetfile does not exist, downloading..." -NoNewLine Start-BitsTransfer -Source "$SourceFile" -Destination "$targetfolder\$targetfile" Write-Host "`b`b`b`b`b`b`b`b`b`b`b`b`b`bdownloaded! " -ForegroundColor Green } }else{ Write-Host "Internet Access not detected. Please resolve and try again." -foregroundcolor red } } #end GetIt Do { if ($RebootRequired -eq $true){write-host "`t`t`t`t`t`t`t`t`t`n`t`t`t`tREBOOT REQUIRED!`t`t`t`n`t`t`t`t`t`t`t`t`t`n`t`tDO NOT INSTALL Lync BEFORE REBOOTING!`t`t`n`t`t`t`t`t`t`t`t`t" -foregroundcolor yellow} if ($opt -ne "None") {write-host "Last command: "$opt -foregroundcolor Yellow} write-host $menu $opt = Read-Host "Select an option.. [1-11]? " switch ($opt) { 1 { Add-WindowsFeature NET-Framework-Core,Telnet-Client,RSAT-ADDS,Web-Static-Content,Web-Default-Doc,Web-Http-Errors,Web-Asp-Net,Web-Net-Ext,Web-ISAPI-Ext,Web-ISAPI-Filter,Web-Http-Logging,Web-Log-Libraries,Web-Http-Tracing,Web-Windows-Auth,Web-Filtering,Web-Stat-Compression,Web-Mgmt-Console,Web-Scripting-Tools,Web-Client-Auth,Desktop-Experience; $RebootRequired = $true } 2 { add-windowsfeature NET-Framework-Core,Telnet-Client,Web-Static-Content,Web-Default-Doc,Web-Http-Errors,Web-Asp-Net,Web-Net-Ext,Web-ISAPI-Ext,Web-ISAPI-Filter,Web-Http-Logging,Web-Log-Libraries,Web-Http-Tracing,Web-Windows-Auth,Web-Filtering,Web-Stat-Compression,Web-Mgmt-Console,Web-Scripting-Tools,Web-Client-Auth; $RebootRequired = $true } 3 { add-windowsfeature NET-Framework-Core,msmq-server,msmq-directory,Telnet-Client } 4 { add-windowsfeature NET-Framework-Core,web-server, web-http-redirect, web-asp-net, web-http-logging, web-log-libraries, web-request-monitor, web-http-tracing, web-basic-auth, web-windows-auth, web-mgmt-console, web-scripting-tools, web-mgmt-compat, was-process-model, was-net-environment, rsat-adds, telnet-client ; $RebootRequired = $true } 5 { add-windowsfeature NET-Framework-Core,Telnet-Client } 6 { add-windowsfeature NET-Framework-Core,Telnet-Client } 7 { add-windowsfeature NET-Framework-Core, web-server, web-mgmt-compat, web-asp-net, msmq-server, msmq-directory, rsat-adds, telnet-client ; $RebootRequired = $true } 8 { GetIt "http://download.microsoft.com/download/1/8/A/18ADD884-E16F-4AD3-8422-FC80073439AA/OCSReskit.msi" Write-Host "Installing..." -ForegroundColor Green cmd.exe /c c:\Install\OCSReskit.msi /qb write-host "Done!" -ForegroundColor Green } 9 { GetIt "http://download.microsoft.com/download/3/3/8/338D2314-1D23-47C1-8BB4-80FD39B84EA6/RTCBPA.msi" Write-Host "Installing..." -ForegroundColor Green cmd.exe /c c:\Install\RTCBPA.msi /qb write-host "Done!" -ForegroundColor Green } 10 { if (($wasinstalled -eq $false) -and (Get-Module BitsTransfer)){Write-Host "Removing BitsTransfer..." -NoNewLine;Remove-Module BitsTransfer;Write-Host "removed!" -ForegroundColor Green};popd;write-host "Exiting and rebooting..."; Restart-Computer} 11 { if (($wasinstalled -eq $false) -and (Get-Module BitsTransfer)){Write-Host "Removing BitsTransfer..." -NoNewLine;Remove-Module BitsTransfer;Write-Host "removed!" -ForegroundColor Green};popd;write-host "Exiting..."} } } while ($opt -ne 11)