SMTP Incoming function assumes R2

Nov 9, 2011 at 12:34 AM

The PowerShell Module ServerManager is not included in 2008 that I know of, so the function fails on 2008 (for me) due to not being able to import the module.  servermanagercmd.exe can be used, so I changed your function handle both, although I didn't handle an error coming back from the exe.

 

# ====================================================================================
# Func: InstallSMTP
# Desc: Installs the SMTP Server Windows feature
# ====================================================================================
Function InstallSMTP
{
	If (ShouldIProvision($xmlinput.Configuration.Farm.Services.SMTP) -eq $true)
	{
		WriteLine
		Write-Host -ForegroundColor White " - Installing SMTP Server feature..."
		$QueryOS = Gwmi Win32_OperatingSystem
  		$QueryOS = $QueryOS.Version 
    	$OS = ""
    	If ($QueryOS.contains("6.1")) {$OS = "Win2008R2"}
    	ElseIf ($QueryOS.contains("6.0")) {$OS = "Win2008"}

		If ($OS -eq "Win2008R2")
		{
			
		Import-Module ServerManager
		Add-WindowsFeature -Name SMTP-Server | Out-Null
		If (!($?)) {Throw " - Failed to install SMTP Server!"}

		}
		Else # Win2008
		{
			
		servermanagercmd.exe -install smtp-server

		}
		Write-Host -ForegroundColor White " - Done."
		WriteLine
	}
}

Coordinator
Nov 9, 2011 at 3:00 AM

What you mean people are still running non-R2? :-)

This should be very easy to drop in, look for it in the next release - thanks!

Brian

Coordinator
Nov 9, 2011 at 3:08 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.