# ===================================================================================
# Install-CopyMove.ps1
# (c) SharePoint Products ApS, 2010-2026
#
# CopyMove 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 CopyMove for SharePoint Server Subscription Edition";
$0 = $myInvocation.MyCommand.Definition;
$dp0 = [System.IO.Path]::GetDirectoryName($0);
. "$dp0\Functions.ps1";

Load-SharePoint-Powershell;

Create-EventSource "SharePoint Products";

Add-FarmSolution "$dp0\..\sharepointproducts_platform.wsp";
Add-FarmSolution "$dp0\..\sharepointproducts_copymove.wsp";

Install-FarmSolution "sharepointproducts_platform.wsp";
Install-FarmSolution "sharepointproducts_copymove.wsp";

Write-Host "Enabling CopyMove farm feature ..." -NoNewline;
start -NoNewWindow -Wait powershell {
	$PSSnapin = Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue;
	Enable-SPFeature -Identity SPPCopyMoveFarm;
}
Write-Host -f Green " success";

Install-PowerShellModule "$dp0\.." "SharePointProducts.Platform.PowerShell";
Install-PowerShellModule "$dp0\.." "SharePointProducts.CopyMove.PowerShell";

Write-Host ""
Write-Host "Installation complete - configure CopyMove as follows:"
Write-Host "1. Navigate to 'Central Administation -> Manage farm features'"
Write-Host "2. Ensure that the feature 'CopyMove for SharePoint Server SE' is activated"
Write-Host "3. Activate the CopyMove web application feature on all applicable web applications"
Write-Host "4. Activate the CopyMove site collection feature on all applicable site collections"
Write-Host "5. Optionally change default settings from 'Central Administration -> CopyMove settings'"
Write-Host "6. Done"
Write-Host ""

Pause

