#################################################################################################### # 1.DEX_Post_Install_config.ps1 # # v01 March2011 by Ryan Barrett # # This is the new build script designed for Exchange 2010 installs # # #################################################################################################### function UpdateExchangelicense ($ExchVersion){ $DEX_Key_file = [xml](get-content "$SetupInstallPathRoot\DEX_Keys.xml" -EA 0) foreach($xmlVersion in $DEX_Key_file.selectNodes("//Exchange/Version")){ switch ($xmlVersion.Name){ "Standard Edition" {$StdVersion = $xmlVersion.Key} "Enterprise Edition" {$EntVersion = $xmlVersion.Key} } } switch ($ExchVersion){ "Exchange Standard" {$StdVersion} "Exchange Enterprise" {$EntVersion} } } $SetupSCOMkey = "HKLM:\SOFTWARE\RACKSPACE\MAC" $objConfigurationPath = "LDAP://" + ([ADSI]'LDAP://RootDSE').configurationNamingContext $objPartitionPath = "LDAP://CN=Partitions," + ([ADSI]'LDAP://RootDSE').configurationNamingContext $colPartition = [ADSI] $objPartitionPath foreach($index in $colPartition.children){ $objDNSName = [ADSI] $index.path if ($objDNSName.nCName -eq ([ADSI]'LDAP://RootDSE').defaultNamingContext){ $objNETBios = $objDNSName.nETBIOSName $objInternalDNSName = $objDNSName.dnsRoot } } $defaultExchangeAdminGroup = "Exchange Administrative Group (FYDIBOHF23SPDLT)" $objHostName = [System.Net.Dns]::GetHostByName("localhost").HostName $outFile = $objHostName + '_' + "Exchange" + '_' +"audit.xml" $SetupInstallPathRoot = Get-Location | Get-Item $SetupInstallPathParent = $SetupInstallPathRoot.Parent.FullName $SetupInstallPath = "$SetupInstallPathParent\Exchange 2010 SP1" if(Test-Path "$SetupInstallPathRoot\$outFile"){ $auditxml = [xml](get-content $outFile -EA 0) $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://$objHostName/powershell/ -Authentication Kerberos Import-PSSession $Session $ServerNode=$auditxml.selectSingleNode("//Organization/InstallServer") $OrgNode=$auditxml.selectSingleNode("//Organization") $ExchKey = UpdateExchangelicense $ServerNode.ExchVersion # Set-ExchangeServer -Identity $objHostName $ExchKey if((Get-OutlookAnywhere) -eq $null){ $objCASFQDN = $OrgNode.ExternalCAS + "." + $OrgNode.ExternalDNS Enable-OutlookAnywhere -Server: -ExternalHostName:''$objCASFQDN'' -SSLOffloading $false } $objDefaultRecConn = Get-ReceiveConnector -Server $objHostName|where{$_.Name -match "Default"} if($objDefaultRecConn -ne $null){ Write-Host "$objDefaultRecConn Receive Connector: " $objDefaultRecConn.PermissionGroups -ForegroundColor green Set-ReceiveConnector $objDefaultRecConn.name -PermissionGroups AnonymousUsers,ExchangeUsers,ExchangeServers,ExchangeLegacyServers Write-Host "`nNew Receive Connector Settings: " $objDefaultRecConn.PermissionGroups -ForegroundColor green } else{ Write-Host "`nIgnored: $objHostName is not a Hub Transport Server" -ForegroundColor green } $ExtSendConn = Get-SendConnector|where{$_.SourceRoutingGroup -ne $defaultExchangeAdminGroup} if($ExtSendConn -ne $null){ $objSendConn = $OrgNode.SendConnector + "." + $OrgNode.ExternalDNS New-SendConnector -Internet -Name "RS Exchange 2010 Send Connector" -AddressSpaces * -FQDN $objSendConn Write-Host "`nSend Connector FQDN: "+ $objSendConn -ForegroundColor green } $LegacyEmailPolicy = get-EmailAddressPolicy|where{$_.RecipientFilterType -eq "Legacy"} $DefaultEmailPolicy = (get-EmailAddressPolicy|where{$_.Identity -eq "Default Policy"}).EnabledEmailAddressTemplates if($LegacyEmailPolicy -eq $null){ foreach($emailPolicy in $DefaultEmailPolicy){ if($emailPolicy.ProxyAddressAddressTemplateString.contains("@" + $OrgNode.ExternalDNS)){ $objemailPolicy = $emailPolicy.ProxyAddressTemplateString } } Write-Host "`nEmail policy found: " $objemailPolicy -ForegroundColor green # $objEmailPolicy = $OrgNode.DefaultEmailPolicy + "@" + $OrgNode.ExternalDNS # Set-EmailAddressPolicy "$DefaultEmailPolicy" -EnabledSMTPAddressTemplates $objEmailPolicy } Remove-PSSession $Session # Check if SCOM Agent is enabled if((Test-Path $SetupSCOMkey)){ if((Get-ItemProperty $SetupSCOMkey).DedicatedExchange -eq "1"){ Write-Host "SCOM Registry Value is already enabled for this server" -ForegroundColor green } else{ Set-ItemProperty -path $key -name DedicatedExchange -Type DWORD -value 1 Write-Host "Added SCOM Support Registry Value for Dedicated Exchange" -ForegroundColor green } } } else{ write-host "Failed: can't find xml file to continue configuration" }