check sharepoint server is standalone or farm mode
2013-03-01 16:43
232 查看
#-----------------------------------------------------------------------------------
# <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
}
# <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
}
相关文章推荐
- SharePoint Designer Check In and Check Out Error – Cannot perform this operation.The file is no longer check out or has been del
- What is server farm in Sharepoint?
- SharePoint Error - The current user is not an SharePoint Server farm administrator
- SharePoint Error - The current user is not an SharePoint Server farm administrator
- How to Check Whether API Server is up or Down
- Fix SharePoint Server 2013 The SDDL string contains an invalid sid or a sid that cannot be translated. Issue
- How to move the databases that are used by SharePoint Portal Server 2003 to a computer that is running SQL Server
- SharePoint Error:a system restart from a previous installation or update is pending
- How to use ASMCA in silent mode to configure ASM for a stand-alone server [ID 1068788.1]
- SharePoint Debug - This file is not a valid presentation file or contains multiple slides...
- How To: Check if a user is part of a SharePoint group in InfoPath
- MOSS爬网问题Error from SharePoint site: Data is Null. This method or property cannot be called on Null values
- Sharepoint Service Error: A deployment or retraction is already under way for the solution "xxx.wsp" , and only one deployment or retraction at a time
- 十分难受的过程.一周的时间,终于把Sharepoint Server 的一个网站集迁移到了另一个FARM中.(一)
- Prepare to back up and restore a farm (Office SharePoint Server 2007)
- 十分难受的过程.一周的时间,终于把Sharepoint Server 的一个网站集迁移到了另一个FARM中.(二)
- Is Microsoft Office SharePoint Server 2007 Ready for Enterprise BPM?
- A system restart from a previous installation or update is pending sharepoint 2010
- Target host or target server ***** is not in operation mode
- Sharepoint Error : The URL "filename" is invalid. It may refer to a nonexistent file or folder, or refer to a valid file or folder that is not in the current Web