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

Archives

Post Categories

Blogs

Forums

Lync

Storage

Tools

Virtualization

Web comics

Powershell: Install Exchange

Another Exchange related function (who could guess!) I recently finished is this one. It will download the Exchange setup file and install the role you require to be installed. You have to provide the role you want to install, the Exchange version and the organization name. Works for 2010 and 2013. Might update this in the future to include RU installations.

 

   1:  function install-exchange 
   2:  {    
   3:      Param( 
   4:          [Parameter(Mandatory=$true,ValueFromPipeline=$true)] 
   5:          [ValidateSet('HUB','CAS','MBX','UM','Edge','Typical')]
   6:          [String]$opt 
   7:      , 
   8:          [Parameter(Mandatory=$true,ValueFromPipeline=$true)] 
   9:          [ValidateSet('2010','2013')]
  10:          [string]$ExchVersion 
  11:      ,
  12:          [Parameter(Mandatory=$true,ValueFromPipeline=$true)] 
  13:          [string]$OrgName 
  14:      )
  15:   
  16:      #Region installation files
  17:      $FileExchange2010= @{'filename'='exchange2013-SP3-x64.exe';
  18:          'shortname'='E2010';
  19:          'displayname'='Exchange 2010 SP3';
  20:          'url'='http://download.microsoft.com/download/3/0/3/30383778-FB6F-429A-9F65-AF1FE57D7017/Exchange2010-SP3-x64.exe';
  21:          'size'='549MB'}
  22:      $fileExchange2013== @{'filename'='exchange2013-x64-cu3.exe';
  23:          'shortname'='E2013';
  24:          'displayname'='Exchange 2013';
  25:          'url'='http://download.microsoft.com/download/3/2/2/3226085F-1B33-4899-8DEA-26E5E60D77BD/Exchange2013-x64-cu3.exe';
  26:          'size'='1.46GB'}
  27:      #endregion
  28:   
  29:      switch($ExchVersion)
  30:      {
  31:          2010
  32:          {
  33:              $appArray=$FileExchange2010
  34:              $checkExpression = "test-path 'HKLM:SOFTWARE\Microsoft\ExchangeServer\v14'"
  35:              
  36:              if($checkExpression)
  37:              {Write-Verbose '$($AppArray.shortname) is already installed' -Verbose}Else{
  38:                  $DownloadPath= "C:\Temp\"
  39:                  $fullPath = Join-Path -Path $DownloadPath -ChildPath $appArray.filename
  40:                  if(!($fullPath)){
  41:                      Write-Host "Downloading $($appArray.shortname)..." -NoNewline
  42:                      $dlClient = New-Object System.Net.WebClient
  43:                      $dlClient.DownloadFile($appArray.url,$fullPath)
  44:                      Write-Host "Done!" -ForegroundColor Green
  45:                  }
  46:              }
  47:              $arguments = ' /extract:C:\Temp\Exchange\ /quiet'
  48:              Write-Host "Extracting Exchange 2010..." -NoNewline
  49:              $process = [System.Diagnostics.Process]::Start($fullPath,$arguments)
  50:              $process.WaitForExit()
  51:              Write-Host "Done!" -ForegroundColor Green
  52:              
  53:              switch($opt)
  54:                  {
  55:                  'Typical'
  56:                      {
  57:                      $E2010 = "C:\Temp\Exchange\setup.com /mode:install /role:CA,HT,MB /on:$OrgName /InstallWindowsComponents"
  58:                      Invoke-Expression $E2010
  59:                      }
  60:                  'UM'
  61:                      {
  62:                      $E2010 = "C:\Temp\Exchange\setup.com /mode:install /role:UM /InstallWindowsComponents"
  63:                      Invoke-Expression $E2010
  64:                      }
  65:                  'Edge'
  66:                      {
  67:                      $E2010 = "C:\Temp\Exchange\setup.com /mode:install /role:ET /on:$OrgName /InstallWindowsComponents"
  68:                      Invoke-Expression $E2010
  69:                      }
  70:          
  71:                  'HUB'
  72:                      {
  73:                      $E2010 = "C:\Temp\Exchange\setup.com /mode:install /role:HT /on:$OrgName /InstallWindowsComponents"
  74:                      Invoke-Expression $E2010
  75:                      }
  76:                  'MBX'
  77:                      {
  78:                      $E2010 = "C:\Temp\Exchange\setup.com /mode:install /role:MB /on:$OrgName /InstallWindowsComponents"
  79:                      Invoke-Expression $E2010
  80:                      }
  81:                  'CAS'
  82:                      {
  83:                      $E2010 = "C:\Temp\Exchange\setup.com /mode:install /role:MB /on:$OrgName /InstallWindowsComponents"
  84:                      Invoke-Expression $E2010
  85:                      }
  86:                  }
  87:          
  88:          }
  89:      
  90:          2013
  91:          {
  92:              $appArray=$FileExchange2013
  93:              $checkExpression = "test-path 'HKLM:SOFTWARE\Microsoft\ExchangeServer\v15'"
  94:              
  95:              if($checkExpression)
  96:              {Write-Verbose '$($AppArray.shortname) is already installed' -Verbose}Else{
  97:                  $DownloadPath= "C:\Temp\"
  98:                  $fullPath = Join-Path -Path $DownloadPath -ChildPath $appArray.filename
  99:                  if(!($fullPath)){
 100:                      Write-Host "Downloading $($appArray.shortname)..." -NoNewline
 101:                      $dlClient = New-Object System.Net.WebClient
 102:                      $dlClient.DownloadFile($appArray.url,$fullPath)
 103:                      Write-Host "Done!" -ForegroundColor Green
 104:                  }
 105:              $arguments = ' /extract:C:\Temp\Exchange\Setup'
 106:              $process = [System.Diagnostics.Process]::Start($fullPath,$arguments)
 107:              $process.WaitForExit()        
 108:              
 109:              switch($opt)
 110:                  {
 111:                  'Typical'
 112:                      {
 113:                      $E2013 = $filepath+"\Exchange\Setup\setup /IAcceptExchangeServerLicenseTerms /Mode:Install /Role:ClientAccess,Mailbox,ManagementTools /InstallWindowsComponents /CustomerFeedbackEnabled:False"
 114:                      Invoke-Expression $E2013
 115:                      }
 116:                  'UM'
 117:                      {
 118:                      Write-Verbose "Role not supported" -Verbose
 119:                      }
 120:                  'Edge'
 121:                      {
 122:                      Write-Verbose "The edge role is not releaased yet" -Verbose
 123:                      }
 124:          
 125:                  'HUB'
 126:                      {
 127:                      Write-Verbose "Role not supported" -Verbose
 128:                      }
 129:                  'MBX'
 130:                      {
 131:                      $E2013 = $filepath+"\Exchange\Setup\setup /IAcceptExchangeServerLicenseTerms /Mode:Install /Role:Mailbox,ManagementTools /InstallWindowsComponents /CustomerFeedbackEnabled:False"
 132:                      Invoke-Expression $E2013
 133:                      }
 134:                  'CAS'
 135:                      {
 136:                      $E2013 = $filepath+"\Exchange\Setup\setup /IAcceptExchangeServerLicenseTerms /Mode:Install /Role:ClientAccess,ManagementTools /InstallWindowsComponents /CustomerFeedbackEnabled:False"
 137:                      Invoke-Expression $E2013
 138:                      }
 139:                  }
 140:              }
 141:          }
 142:      }
 143:      
 144:      
 145:      
 146:  }

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

Feedback

No comments posted yet.
Post A Comment
Title:
Name:
Email:
Comment:
Verification:
 

Powered by: