posts - 104 , comments - 115 , trackbacks - 0

My Links

News

Disclaimer: Right here... Github: Code all the things! PS GUI Series: < Coming Soon! > PS Scripts: < Coming Soon! >

Tag Cloud

Article Categories

Archives

Post Categories

Image Galleries

Blogs

Forums

Lync

Storage

Tools

Virtualization

Web comics

Powershell: Prepare for an Exchange installation

I’m not taking full credit for this one. This script was originally made by someone else (and as soon as I find the link to that post I’ll put it up!) to prepare for Exchange 2010 on windows 2008 and 2008 R2.

I’ve updated it for server 2012 and Exchange 2013, converted it to a function and make you choose the role you are preparing the server for straight away when running the function.

And yes you need all the functions listed here to make it work!

 

   1:  Function InstallApp($app)
   2:      {
   3:          if (!($installedUpdates))
   4:              {
   5:              Write-Host 'Loading list of installed hotfixes...'
   6:              $installedUpdates = Get-WmiObject win32_quickfixengineering
   7:              }
   8:          switch ($app)
   9:              {
  10:              'Exchange2010'
  11:                  {
  12:                  $appArray=$FileExchange2010
  13:                  $checkExpression = "test-path 'HKLM:SOFTWARE\Microsoft\ExchangeServer\v14'"
  14:                  }
  15:              'WinRM' 
  16:                  {
  17:                  $appArray = $fileWinRM
  18:                  $kb = 'KB968930'
  19:                  }
  20:              'NET35'
  21:                  {
  22:                  $appArray = $fileNET35
  23:                  $checkExpression = "test-path 'HKLM:Software\Microsoft\NET Framework Setup\NDP\v3.5'"
  24:                  }
  25:              'NET35HF'
  26:                  {
  27:                  $appArray = $fileNET35HF
  28:                  $checkExpression = "test-path 'HKLM:SOFTWARE\Wow6432Node\Microsoft\Updates\Microsoft .NET Framework 3.5 SP1\SP1\KB958484'"
  29:                  }
  30:              'OFP'
  31:                  {
  32:                  $appArray = $fileOFP
  33:                  $checkExpression = "test-path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\{95140000-2000-0409-1000-0000000FF1CE}'"
  34:                  }
  35:              'UCMA'
  36:                  {
  37:                  $appArray = $fileUCMARuntime
  38:                  $checkExpression = "test-path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{7EB901DD-CB50-4046-A434-3E9A112E8F86}'"
  39:                  }
  40:              'SSRT'
  41:                  {
  42:                  $appArray = $fileSSRT
  43:                  $checkExpression = "test-path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{3B433087-E62E-4BF5-97F9-4AF6E1C2409C}'"
  44:                  }
  45:              'KB977624'
  46:                  {
  47:                  $appArray = $fileKB977624
  48:                  $kb = 'KB977624'
  49:                  }
  50:              'KB979744'
  51:                  {
  52:                  $appArray = $fileKB979744
  53:                  $kb = 'KB979744'
  54:                  }
  55:              'KB979744R2'
  56:                  {
  57:                  $appArray = $fileKB979744R2
  58:                  $kb = 'KB979744'
  59:                  }
  60:              'KB973136'
  61:                  {
  62:                  $appArray = $fileKB973136
  63:                  $kb = 'KB973136'
  64:                  }
  65:              'KB977592'
  66:                  {
  67:                  $appArray = $fileKB977592
  68:                  $kb = 'KB977592'
  69:                  }
  70:              'KB979099'
  71:                  {
  72:                  $appArray = $fileKB979099
  73:                  $kb = 'KB979099'
  74:                  }
  75:              'KB983440'
  76:                  {
  77:                  $appArray = $fileKB983440
  78:                  $kb = 'KB983440'
  79:                  }
  80:              'KB977020'
  81:                  {
  82:                  $appArray = $fileKB977020
  83:                  $kb = 'KB977020'
  84:                  }
  85:              default
  86:                  {
  87:                  Write-Error 'Unknown Application'
  88:                  PAUSE
  89:                  EXIT
  90:                  }
  91:   
  92:              }
  93:          trap
  94:              {
  95:              Write-Host ''
  96:              Write-Host "There was a problem downloading or installing $($appArray.shortname)." -ForegroundColor Red
  97:              Write-Host ''
  98:              break
  99:              }
 100:          #Check for existing installation
 101:          Write-Host "Verifying $($appArray.displayname) is installed..." -NoNewline
 102:          if (($app -eq 'WinRM') -or ($app -like 'KB*'))
 103:              {
 104:              if ($installedUpdates -match $kb)
 105:                  {
 106:                  $bInstalled = $true
 107:                  }
 108:              else
 109:                  {
 110:                  $bInstalled = $false
 111:                  }
 112:              }
 113:          else
 114:              {
 115:              if (Invoke-Expression $checkExpression)
 116:                  {
 117:                  $bInstalled = $true
 118:                  }
 119:              else
 120:                  {
 121:                  $bInstalled = $false
 122:                  }
 123:              }
 124:          if ($bInstalled)
 125:              {
 126:              Write-Host "$($appArray.displayname) is installed." -ForegroundColor Green
 127:              return
 128:              }
 129:          Write-Host "$($appArray.displayname) is not installed." -ForegroundColor Yellow
 130:          Write-Host "Installing $($appArray.displayname)..." -NoNewline
 131:          
 132:          #Install app:  Check for existing installation file.
 133:          $fullPath = $sourcePath+"\$($appArray.filename)"
 134:          if (!(Test-Path $fullPath))
 135:              {
 136:              Write-Host ''
 137:              Write-Host "$($appArray.filename) not found in source path." -ForegroundColor Yellow
 138:              if (($app -eq 'KB977624') -or ($app -eq 'KB977592'))
 139:                  {
 140:                  Write-Host "$($apparray.displayname) can only be downloaded from the Premier website," -ForegroundColor Red
 141:                  Write-Host "$($apparray.url) or by requesting it from Microsoft." -ForegroundColor Red
 142:                  break
 143:                  }
 144:              if (($app -eq 'KB979744') -or ($app -eq 'KB979744R2') -or ($app -eq 'KB979917') -or ($app -eq 'KB973136') -or ($app -eq 'KB983440') -or ($app -eq 'KB977020'))
 145:                  {
 146:                  Write-Host "$($apparray.displayname) must be manually downloaded: " -ForegroundColor Red
 147:                  Write-Host "$($apparray.url)"
 148:                  break
 149:                  }
 150:   
 151:              Write-Host "Downloading $($appArray.shortname)..." -NoNewline
 152:              $dlClient = New-Object System.Net.WebClient
 153:              $dlClient.DownloadFile($appArray.url,$fullPath)
 154:              if (!(Test-Path $fullPath))
 155:                  {
 156:                  Write-Host ''
 157:                  Write-Host "There was a problem downloading $($appArray.shortname)." -ForegroundColor Red
 158:                  Write-Host ''
 159:                  }
 160:              else
 161:                  {
 162:                  Write-Host 'done.' -ForegroundColor Green
 163:                  }
 164:              }
 165:          
 166:          
 167:      #Install app: Run installation.
 168:      SWITCH($app)
 169:      {
 170:          'WinRM'
 171:              {
 172:                  $expression = "wusa $fullPath /quiet"
 173:                  Invoke-Expression $expression
 174:                  Write-Host 'External update process started...Be patient, it takes time.' -ForegroundColor Yellow
 175:                  Write-Host ''
 176:                  Write-Host 'When the WinRM installation is complete, the system will automatically reboot.'
 177:                  Write-Host 'Then you can rerun the script to continue.  This script will now end.'
 178:                  break
 179:              }
 180:          'NET35HF'
 181:              {
 182:                  {$arguments = '/passive /norestart'}
 183:              }
 184:          default
 185:              {
 186:                  {$arguments = '/quiet /norestart'}
 187:                  $process = [System.Diagnostics.Process]::Start($fullPath,$arguments)
 188:                  $process.WaitForExit()
 189:                  Write-Host "$($appArray.displayname) installation complete." -ForegroundColor Green
 190:              }
 191:          'Exchange2013'{}
 192:      
 193:      }
 194:  }
 195:       
 196:  Function InstallNET35($os)
 197:      {
 198:          InstallApp 'NET35'
 199:          If (-not($os -eq 'Win7'))
 200:              {
 201:              InstallApp 'NET35HF'
 202:              }
 203:          }
 204:       
 205:  function InstallHotfixes($os)
 206:      {
 207:   
 208:          if ($os -eq 'R1')
 209:              {
 210:              InstallApp 'KB977624'
 211:              InstallApp 'KB979744'
 212:              InstallApp 'KB979917'
 213:              InstallApp 'KB973136'
 214:              InstallApp 'KB977592'
 215:              }
 216:          elseif (($os -eq 'R2') -and (($opt -eq 2) -or ($opt -eq 6) -or ($opt -eq 7)))
 217:              {
 218:              InstallApp 'KB979099'
 219:              InstallApp 'KB979744R2'
 220:              InstallApp 'KB983440'
 221:              InstallApp 'KB977020'
 222:              }
 223:          elseif (($os -eq 'R2') -and (($opt -eq 1) -or ($opt -eq 3)))
 224:              {
 225:              InstallApp 'KB979099'
 226:              }
 227:          elseif ($os -eq 'Win7')
 228:              {
 229:              #InstallApp 'KB977020'
 230:              #InstallApp 'KB983440'
 231:              }
 232:          }
 233:   
 234:  Function SetTCPSharing()
 235:      {
 236:          trap
 237:              {
 238:              Write-Host ''
 239:              Write-Host 'There was problem setting the NET TCP Port Sharing service to Automatic startup.' -ForegroundColor Red
 240:              Write-Host 'The service must be set to Automatic for Exchange setup to be successful.' -ForegroundColor Red
 241:              Write-Host ''
 242:              return
 243:              }    
 244:          #Set NETTCPPortSharing to Automatic
 245:          Write-Host 'Configuring the NET TCP Port Sharing service...' -NoNewline
 246:          Set-Service NetTcpPortSharing -StartupType Automatic
 247:          Write-Host 'done.' -ForegroundColor Green
 248:          }
 249:   
 250:  Function EnableRemoting()
 251:      {
 252:          trap
 253:              {
 254:              Write-Host ''
 255:              Write-Host 'There was problem configuring the system for remote PowerShell.' -ForegroundColor Red
 256:              Write-Host ''
 257:              return
 258:              }
 259:          #Enable Remote PowerShell for Exchange administration from workstations
 260:          Write-Host 'Enabling system for remote PowerShell connections...'
 261:          Enable-PSRemoting -force
 262:          Write-Host 'Remote PowerShell configuration is done.' -ForegroundColor Green
 263:          }
 264:   
 265:  Function EnableFirewall()
 266:      {
 267:          trap
 268:              {
 269:              Write-Host ''
 270:              Write-Host 'There was problem starting the Windows Firewall service.' -ForegroundColor Red
 271:              Write-Host 'The firewall service must be running during Exchange setup.  It can be stopped after it completes.' -ForegroundColor Red
 272:              Write-Host ''
 273:              return
 274:              }    
 275:          #Ensure Windows Firewall is running or Exchange install will fail
 276:          Write-Host 'Starting the Windows Firewall service...' -NoNewline
 277:          Set-Service 'MpsSvc' -StartupType Automatic -Status Running
 278:          Write-Host 'done.' -ForegroundColor Green
 279:          }
 280:          
 281:  Function Prepare-Exchange
 282:  {
 283:   
 284:      #region    Installation files and properties
 285:      $FileExchange2010= @{'filename'='exchange2010-SP3-X64.exe';
 286:          'shortname'='E2010';
 287:          'displayname'='Exchange 2010 SP3';
 288:          'url'='http://download.microsoft.com/download/3/0/3/30383778-FB6F-429A-9F65-AF1FE57D7017/Exchange2010-SP3-x64.exe';
 289:          'size'='549MB'}
 290:      $fileWinRM = @{'filename'='Windows6.0-KB968930-x64.msu';
 291:          'shortname'='WinRM';
 292:          'displayname'='Windows Remote Management Framework';
 293:          'url'='http://download.microsoft.com/download/2/8/6/28686477-3242-4E96-9009-30B16BED89AF/Windows6.0-KB968930-x64.msu';
 294:          'size'='14MB'}
 295:      $fileNET35 = @{'filename'='dotnetfx35.exe';
 296:          'shortname'='.NET 3.5';
 297:          'displayname'='.NET 3.5 SP1';
 298:          'url'='http://download.microsoft.com/download/2/0/E/20E90413-712F-438C-988E-FDAA79A8AC3D/dotnetfx35.exe';
 299:          'size'='235MB'}
 300:      $fileNET35HF = @{'filename'='NDP35SP1-KB958484-x64.exe';
 301:          'shortname'='.NET 3.5 hotfix';
 302:          'displayname'='.NET 3.5 hotfix';
 303:          'url'='http://download.microsoft.com/download/B/4/2/B42197BD-AEE1-4FE6-8CB3-29D60D0C3727/NDP35SP1-KB958484-x64.exe';
 304:          'size'='1.4MB'}
 305:      #This is the SP1 version of the filter pack, but there are no changes in SP1 that impact Exchange,
 306:      #so the RTM version is also sufficient.
 307:      $fileOFP = @{'filename'='2010FilterPack64bit.exe';
 308:          'shortname'='Office 2010 Filter Pack';
 309:          'displayname'='Office 2010/2007 Filter Pack';
 310:          'url'='http://download.microsoft.com/download/0/A/2/0A28BBFA-CBFA-4C03-A739-30CCA5E21659/FilterPack64bit.exe';
 311:          'size'='4MB'}
 312:      $fileKB977624 = @{'filename'='Windows6.0-KB977624-v2-x64.msu';
 313:          'shortname'='KB977624';
 314:          'displayname'='KB 977624 v2';
 315:          'url'='https://premier.microsoft.com/kb/977624';
 316:          'size'='3MB'}
 317:      $fileKB979744 = @{'filename'='Windows6.0-KB979744-v2-x64.msu';
 318:          'shortname'='KB979744';
 319:          'displayname'='KB 979744 v2';
 320:          'url'='http://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=27109';
 321:          'size'='10MB'}
 322:      $fileKB979744R2 = @{'filename'='Windows6.1-KB979744-v2-x64.msu';
 323:          'shortname'='KB979744';
 324:          'displayname'='KB 979744 v2';
 325:          'url'='http://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=27109';
 326:          'size'='10MB'}    
 327:      $fileKB979917 = @{'filename'='Windows6.0-KB979917-x64.msu';
 328:          'shortname'='KB979917';
 329:          'displayname'='KB 979917';
 330:          'url'='http://archive.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=KB979917&DownloadId=12756';
 331:          'size'='3MB'}
 332:      $fileKB973136 = @{'filename'='Windows6.0-KB973136-x64.msu';
 333:          'shortname'='KB973136';
 334:          'displayname'='KB 973136';
 335:          'url'='https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=20922';
 336:          'size'='700KB'}
 337:      $fileKB977592 = @{'filename'='Windows6.0-KB977592-x64.msu';
 338:          'shortname'='KB977592';
 339:          'displayname'='KB 977592';
 340:          'url'='https://premier.microsoft.com/kb/977592';
 341:          'size'='300KB'}
 342:      $fileKB979099 = @{'filename'='Windows6.1-KB979099-x64.msu';
 343:          'shortname'='KB979099';
 344:          'displayname'='KB 979099';
 345:          'url'='http://download.microsoft.com/download/1/F/B/1FB7F377-CB25-4D51-B4A7-D3F05B7A55CA/Windows6.1-KB979099-x64.msu';
 346:          'size'='2MB'}
 347:      $fileKB983440 = @{'filename'='Windows6.1-KB983440-x64.msu';
 348:          'shortname'='KB983440';
 349:          'displayname'='KB 983440';
 350:          'url'='http://archive.msdn.microsoft.com/KB983440/Release/ProjectReleases.aspx?ReleaseId=4410';
 351:          'size'='3MB'}
 352:      $fileKB977020 = @{'filename'='Windows6.1-KB977020-v2-x64.msu';
 353:          'shortname'='KB977020';
 354:          'displayname'='KB 977020 v2';
 355:          'url'='http://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=27977';
 356:          'size'='600KB'}
 357:      $fileUCMARuntime = @{'filename'='UCMARuntimeSetup.exe';
 358:          'shortname'='UCMARuntime';
 359:          'displayname'='Unified Communications Managed API 2.0';
 360:          'url'='http://download.microsoft.com/download/5/8/4/58494AD4-4091-457F-B23D-E57D211D2B5D/UcmaRuntimeSetup.exe';
 361:          'size'='16MB'}
 362:      $fileSSRT = @{'filename'='SpeechPlatformRuntime.msi';
 363:          'shortname'='SpeechPlatform';
 364:          'displayname'='Speech Platform - Server Runtime';
 365:          'url'='http://download.microsoft.com/download/0/4/0/040235F1-3798-4B10-BB36-FAF870A8D559/Runtime/x64/SpeechPlatformRuntime.msi';
 366:          'size'='3MB'}
 367:      #endregion
 368:   
 369:      #     Detect correct OS here and exit if no match
 370:      $wmiOS = Get-WMIObject win32_OperatingSystem
 371:      $OScap = $wmiOS.Caption
 372:      $OSver = $wmiOS.Version
 373:      [array]$wmiProc = Get-WmiObject win32_Processor
 374:      
 375:      #    Finding what CPU architeture the script is running on
 376:      if ($wmiProc[0].Architecture -eq '9')
 377:          {
 378:          if ($OScap -match 'Windows 7')
 379:              {$os = 'Win7'}
 380:          elseif (($OSver.Contains('6.1')) -and ($OScap -match '2008'))
 381:              {$os = 'R2'}
 382:          elseif (($OSver.Contains('6.0')) -and ($OScap -match '2008'))
 383:              {$os = 'R1'}
 384:          elseif (($OSver.contains('6.2')) -and ($OScap -match '2012'))
 385:              {$os = '2012'}
 386:          else
 387:              {
 388:              Write-Host 'The script requires Windows Server 2012 or 2008 with SP2, R2, or Windows 7 for the management tools, which this is not.' -ForegroundColor Red -BackgroundColor Black
 389:              break
 390:              }
 391:          }
 392:      else
 393:          {
 394:           Write-Host 'Exchange 2010/2013 require x64 architecture, which this is not.' -ForegroundColor Red -BackgroundColor Black
 395:          break
 396:          }
 397:          
 398:      #    Exchange 2010 code
 399:      if($ExchVersion -eq '2010')
 400:      {
 401:      switch ($os)
 402:          {
 403:          'Win7'
 404:              {
 405:              $tools = '. dism /Online /Enable-Feature /FeatureName:IIS-WebServerRole /FeatureName:IIS-WebServerManagementTools /FeatureName:IIS-IIS6ManagementCompatibility /FeatureName:IIS-Metabase /FeatureName:IIS-LegacySnapIn; . dism /Online /Disable-Feature /FeatureName:IIS-WebServer /NoRestart'
 406:              }
 407:          'R1'
 408:              {
 409:              $ht = '. ServerManagerCmd.exe -i NET-Framework RSAT-ADDS Web-Server Web-Basic-Auth Web-Windows-Auth Web-Metabase Web-Net-Ext Web-Lgcy-Mgmt-Console WAS-Process-Model RSAT-Web-Server'
 410:              $cas = '. ServerManagerCmd.exe -i NET-Framework RSAT-ADDS Web-Server Web-Basic-Auth Web-Windows-Auth Web-Metabase Web-Net-Ext Web-Lgcy-Mgmt-Console WAS-Process-Model RSAT-Clustering RSAT-Web-Server Web-ISAPI-Ext Web-Digest-Auth Web-Dyn-Compression NET-HTTP-Activation RPC-over-HTTP-proxy Web-WMI'
 411:              $mbx = '. ServerManagerCmd.exe -i NET-Framework RSAT-ADDS Web-Server Web-Basic-Auth Web-Windows-Auth Web-Metabase Web-Net-Ext Web-Lgcy-Mgmt-Console WAS-Process-Model RSAT-Clustering RSAT-Web-Server'
 412:              $um = '. ServerManagerCmd.exe -i NET-Framework RSAT-ADDS Web-Server Web-Basic-Auth Web-Windows-Auth Web-Metabase Web-Net-Ext Web-Lgcy-Mgmt-Console WAS-Process-Model RSAT-Web-Server Desktop-Experience'
 413:              $edge = '. ServerManagerCmd.exe -i NET-Framework RSAT-ADDS ADLDS'
 414:              $typical = '. ServerManagerCmd.exe -i NET-Framework RSAT-ADDS Web-Server Web-Basic-Auth Web-Windows-Auth Web-Metabase Web-Net-Ext Web-Lgcy-Mgmt-Console WAS-Process-Model RSAT-Clustering RSAT-Web-Server Web-ISAPI-Ext Web-Digest-Auth Web-Dyn-Compression NET-HTTP-Activation RPC-over-HTTP-proxy Web-WMI'
 415:              $tools = '. ServerManagerCmd.exe -i Web-Lgcy-Mgmt-Console'
 416:              }
 417:          'R2'
 418:              {
 419:              $ht = 'Add-WindowsFeature NET-Framework,RSAT-ADDS,Web-Server,Web-Basic-Auth,Web-Windows-Auth,Web-Metabase,Web-Net-Ext,Web-Lgcy-Mgmt-Console,WAS-Process-Model,RSAT-Web-Server -restart'
 420:              $cas = 'Add-WindowsFeature NET-Framework,RSAT-ADDS,Web-Server,Web-Basic-Auth,Web-Windows-Auth,Web-Metabase,Web-Net-Ext,Web-Lgcy-Mgmt-Console,WAS-Process-Model,RSAT-Web-Server,Web-ISAPI-Ext,Web-Digest-Auth,Web-Dyn-Compression,NET-HTTP-Activation,RPC-Over-HTTP-Proxy,Web-WMI -restart'
 421:              $mbx = 'Add-WindowsFeature NET-Framework,RSAT-ADDS,Web-Server,Web-Basic-Auth,Web-Windows-Auth,Web-Metabase,Web-Net-Ext,Web-Lgcy-Mgmt-Console,WAS-Process-Model,RSAT-Web-Server -restart'
 422:              $um = 'Add-WindowsFeature NET-Framework,RSAT-ADDS,Web-Server,Web-Basic-Auth,Web-Windows-Auth,Web-Metabase,Web-Net-Ext,Web-Lgcy-Mgmt-Console,WAS-Process-Model,RSAT-Web-Server,Desktop-Experience -restart'
 423:              $edge = 'Add-WindowsFeature NET-Framework,RSAT-ADDS,ADLDS -restart'
 424:              $typical = 'Add-WindowsFeature NET-Framework,RSAT-ADDS,Web-Server,Web-Basic-Auth,Web-Windows-Auth,Web-Metabase,Web-Net-Ext,Web-Lgcy-Mgmt-Console,WAS-Process-Model,RSAT-Web-Server,Web-ISAPI-Ext,Web-Digest-Auth,Web-Dyn-Compression,NET-HTTP-Activation,RPC-Over-HTTP-Proxy,Web-WMI -restart'
 425:              $tools = 'Add-WindowsFeature NET-Framework,Web-Lgcy-Mgmt-Console -restart'
 426:              Import-Module ServerManager
 427:              }
 428:          '2012'
 429:              {
 430:              $ht = 'Add-WindowsFeature RSAT-ADDS,NET-Framework-Features,NET-HTTP-Activation,RPC-over-HTTP-proxy,RSAT-Clustering,Web-Mgmt-Console,WAS-Process-Model,Web-Asp-Net,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-Net-Ext,Web-Request-Monitor,Web-Server,Web-Static-Content,Web-Windows-Auth,Web-WMI -Restart'
 431:              $cas = 'Add-WindowsFeature RSAT-ADDS,NET-Framework-Features,NET-HTTP-Activation,RPC-over-HTTP-proxy,RSAT-Clustering,Web-Mgmt-Console,WAS-Process-Model,Web-Asp-Net,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-Net-Ext,Web-Request-Monitor,Web-Server,Web-Static-Content,Web-Windows-Auth,Web-WMI -Restart'
 432:              $mbx = 'Add-WindowsFeature RSAT-ADDS,NET-Framework-Features,RSAT-Clustering,Web-Mgmt-Console,WAS-Process-Model,Web-Basic-Auth,Web-Lgcy-Mgmt-Console,Web-Metabase,Web-Net-Ext,Web-Server,Web-Windows-Auth -Restart'
 433:              $um = 'Add-WindowsFeature RSAT-ADDS,NET-Framework-Features,Desktop-Experience,Web-Mgmt-Console,WAS-Process-Model,Web-Basic-Auth,Web-Lgcy-Mgmt-Console,Web-Metabase,Web-Net-Ext,Web-Server,Web-Windows-Auth -Restart'
 434:              $edge = 'Add-WindowsFeature ADLDS,NET-Framework-Features -Restart'
 435:              $typical = 'Add-WindowsFeature RSAT-ADDS,NET-Framework-Features,NET-HTTP-Activation,RPC-over-HTTP-proxy,RSAT-Clustering,Web-Mgmt-Console,WAS-Process-Model,Web-Asp-Net,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-Net-Ext,Web-Request-Monitor,Web-Server,Web-Static-Content,Web-Windows-Auth,Web-WMI -Restart'
 436:              Import-Module ServerManager
 437:              }
 438:          }
 439:      }
 440:      
 441:      #    Exchange 2013 code
 442:      If($ExchVersion -eq '2013')
 443:      {
 444:      switch($os)
 445:          {
 446:          'R2'
 447:              {
 448:              $ht = 'Write-warning "This role is not applicable to 2013."'
 449:              $cas = '. Add-WindowsFeature RSAT-ADDS,Desktop-Experience, NET-Framework, NET-HTTP-Activation, RPC-over-HTTP-proxy, RSAT-Clustering, RSAT-Web-Server, WAS-Process-Model, Web-Asp-Net, 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-Ext, Web-Request-Monitor, Web-Server, Web-Stat-Compression, Web-Static-Content, Web-Windows-Auth, Web-WMI'
 450:              $mbx = '. Add-WindowsFeature RSAT-ADDS,Desktop-Experience, NET-Framework, NET-HTTP-Activation, RPC-over-HTTP-proxy, RSAT-Clustering, RSAT-Web-Server, WAS-Process-Model, Web-Asp-Net, 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-Ext, Web-Request-Monitor, Web-Server, Web-Stat-Compression, Web-Static-Content, Web-Windows-Auth, Web-WMI'
 451:              $um = 'Write-warning "This role is not applicable to 2013."'
 452:              $edge = 'Write-warning "This role has not been released."'
 453:              $typical = '. Add-WindowsFeature RSAT-ADDS,Desktop-Experience, NET-Framework, NET-HTTP-Activation, RPC-over-HTTP-proxy, RSAT-Clustering, RSAT-Web-Server, WAS-Process-Model, Web-Asp-Net, 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-Ext, Web-Request-Monitor, Web-Server, Web-Stat-Compression, Web-Static-Content, Web-Windows-Auth, Web-WMI'
 454:              Import-Module ServerManager
 455:              }
 456:          '2012'
 457:              {
 458:              $ht = 'Write-warning "This roleis not applicable to 2013."'
 459:              $cas = 'Install-WindowsFeature RSAT-ADDS,AS-HTTP-Activation, Desktop-Experience, 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'
 460:              $mbx = 'Install-WindowsFeature RSAT-ADDS,AS-HTTP-Activation, Desktop-Experience, 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'
 461:              $um = 'Write-warning "This role is not applicable to 2013."'
 462:              $edge = 'Write-warning "This role has not been released."'
 463:              $typical = 'Install-WindowsFeature RSAT-ADDS,AS-HTTP-Activation, Desktop-Experience, 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'
 464:              }
 465:          }
 466:      }
 467:   
 468:      #    Specific 2008 R1 code
 469:      if ($os -eq 'R1')
 470:      {
 471:          InstallApp 'WinRM'
 472:      }
 473:      
 474:      #    Execution 
 475:      switch ($opt)
 476:          {
 477:              HUB{
 478:                  if($os -ne '2012'){InstallNET35 $os}
 479:                  InstallApp 'OFP'; EnableFirewall; EnableRemoting; InstallHotfixes $os
 480:                  Write-Host 'Beginning Windows components installation...'
 481:                  Invoke-Expression $ht
 482:                    }
 483:              MBX{
 484:                  if($os -ne '2012'){InstallNET35 $os}
 485:                  InstallApp 'OFP'; EnableFirewall; EnableRemoting; InstallHotfixes $os
 486:                  Write-Host 'Beginning Windows components installation...'
 487:                  Invoke-Expression $mbx
 488:                  }
 489:              UM{
 490:                  if($os -ne '2012'){InstallNET35 $os}
 491:                  InstallApp 'UCMA'; InstallApp 'SSRT'; EnableRemoting; EnableFirewall; InstallHotfixes $os
 492:                  Write-Host 'Beginning Windows components installation...'
 493:                  Invoke-Expression $um
 494:                  }
 495:              Edge{
 496:                  if($os -ne '2012'){InstallNET35 $os}
 497:                  EnableFirewall; InstallHotfixes $os
 498:                  Write-Host 'Beginning Windows components installation...'
 499:                  Invoke-Expression $edge
 500:                  }
 501:              Typical{
 502:                  if($os -ne '2012'){InstallNET35 $os}
 503:                  if(($os -ne '2012') -and ($ExVersion -eq '2013')){}
 504:                  InstallApp 'UCMA'; installApp 'OFP' ; EnableFirewall; EnableRemoting; InstallHotfixes $os
 505:                  Write-Host 'Beginning Windows components installation...'
 506:                  Invoke-Expression $typical
 507:                  SetTCPSharing
 508:                  }
 509:              CAS{
 510:                  if($os -ne '2012'){InstallNET35 $os}
 511:                  InstallApp 'UCMA'; EnableFirewall; EnableRemoting; InstallHotfixes
 512:                  Write-Host 'Beginning Windows components installation...'
 513:                  Invoke-Expression $cas
 514:                  SetTCPSharing
 515:                  }
 516:              }
 517:  }

Print | posted on Wednesday, December 18, 2013 12:13 PM | Filed Under [ Exchange Platforms Powershell Deployment ]

Feedback

Gravatar

# re: Powershell: Prepare for an Exchange installation

link for old wondows Server and old exchange for hybrid deployment
http://www.ehloworld.com/152
2/19/2016 1:01 AM | Eddie
Post A Comment
Title:
Name:
Email:
Comment:
Verification:
 

Powered by: