# ===================================================================================
# Install-Platform.ps1
# (c) SharePoint Products 2010-2022
#
# SharePoint Products Platform install script
# ===================================================================================

$myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent()
$myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID)
$adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator
if ($myWindowsPrincipal.IsInRole($adminRole))
{
	$Host.UI.RawUI.BackgroundColor = "DarkBlue"
	clear-host
} else
{
    $arguments = $myInvocation.MyCommand.Definition;
    Start-Process powershell.exe -Verb RunAs -ArgumentList "-file `"$arguments`"";
    exit;
}

$Host.UI.RawUI.WindowTitle = "Installing SharePoint Products Platform"
$0 = $myInvocation.MyCommand.Definition
$dp0 = [System.IO.Path]::GetDirectoryName($0)
. "$dp0\Functions.ps1"

Load-SharePoint-Powershell

EnsureEventSource "SharePoint Products"

Write-Host "- Adding solution"
AddFarmSolution("$dp0\..\sharepointproducts_platform.wsp")

Write-Host "- Deploying solution"
InstallFarmSolution("sharepointproducts_platform.wsp")

Write-Host "- Enabling SPPPlatformFarm feature"
Enable-SPFeature -Identity SPPPlatformFarm

Pause

