# ===================================================================================
# Get-CopyMoveLogFile.ps1
# (c) SharePoint Products ApS, 2010-2026
#
# CopyMove log file 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 = "Merging CopyMove log file"
$0 = $myInvocation.MyCommand.Definition
$dp0 = [System.IO.Path]::GetDirectoryName($0)
. "$dp0\Functions.ps1"

Load-SharePoint-Powershell

Write-Host ""
Write-Host ""
Write-Host ""
Write-Host ""
Write-Host "Merging recent CopyMove log events from all servers in the farm"
Merge-SPLogFile -Path "$dp0\..\CopyMove.log" -Area "SharePoint Products" -Overwrite;
Write-Host "Log events written to the file CopyMove.log"
Write-Host "Done"

