#-----------------------------------------------------------------------------------
# <summary>
# Check the SUT server installation mode.
# </summary>
# <param name="sutVersion">The sut server version.
# Note:its value is gotton by calling function "GetSharePointServerVersion"</param>
# <param name="computerName">The computer name of the server.</param>
# <param name="userName">The user name of the server, must be in the format DOMAIN\User_Alias.</param>
# <param name="password">The password of the user name.</param>
# <returns>
# A string value, true if the server installation mode is StandAlone, otherwise false.
# </returns>
#-----------------------------------------------------------------------------------
function CheckServerInstallationMode
{
param(
[String]$sutVersion,
[String]$computerName,
[String]$userName,
[String]$password
)
#----------------------------------------------------------------------------
# Parameter validation
#----------------------------------------------------------------------------
if($sutVersion -eq $null -or $sutVersion -eq "")
{
Throw "Parameter sutVersion cannot be empty."
}
if($computerName -eq $null -or $computerName -eq "")
{
Throw "Parameter computerName cannot be empty."
}
if($userName -eq $null -or $userName -eq "")
{
Throw "Parameter userName cannot be empty."
}
if($password -eq $null -or $password -eq "")
{
Throw "Parameter password cannot be empty."
}
switch($sutVersion)
{
{$_ -eq "WindowsSharePointServices3" -or $_ -eq "SharePointServer2007"} {$sutShortVersion = "12.0"; break}
{$_ -eq "SharePointFoundation2010" -or $_ -eq "SharePointServer2010"} {$sutShortVersion = "14.0"; break}
{$_ -eq "SharePointFoundation2013" -or $_ -eq "SharePointServer2013"} {$sutShortVersion = "15.0"; break}
}
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$credential = new-object Management.Automation.PSCredential($userName,$securePassword)
$isStandaloneInstallation = invoke-command -computer $computerName -Credential $credential -ErrorAction SilentlyContinue -scriptblock{
param(
[string]$sutShortVersion
)
$ServerModeChildItem = get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\$sutShortVersion\WSS"
$isStandaloneInstallation = "false"
if($ServerModeChildItem.ServerRole -ieq "SINGLESERVER")
{
$isStandaloneInstallation = "true"
}
return $isStandaloneInstallation
}-ArgumentList $sutShortVersion
if($isStandaloneInstallation -eq $null -or $isStandaloneInstallation -eq "")
{
Output "Select the SUT server installation mode: " "Cyan"
Output "1: Standalone mode" "Cyan"
Output "2: Farm mode" "Cyan"
$isStandaloneInstallation = @('1','2')
While(1)
{
[String]$readLine = Read-Host
if($isStandaloneInstallation -contains $readLine)
{
break
}
else
{
Output """$readLine"" is not a correct input, retry with a correct number from the values listed." "Yellow"
}
}
if ($readLine -eq "1")
{
$isStandaloneInstallation = "true"
Output "Your input SUT server installation mode is StandAlone" "Yellow"
}
else
{
$isStandaloneInstallation = "false"
Output "Your input SUT server installation mode is Farm" "Yellow"
}
}
return $isStandaloneInstallation
}