Monday, February 27, 2017

Get SharePoint logs

It is getting old PowerShell script but did need it recently. The script collection log files from all the servers in the farm for a given period.

Tip: $time is the copy/paste value from the SharePoint error message box.

$time = "23-02-2017 11:26:52"
$time = $time.Trim()
$timeToAdd = 10
$startTime = [Datetime]::Parse($time)
$endTime = $startTime.AddSeconds($timeToAdd)
$path = "c:\temp\log $($time.Replace(":", [String]::Empty)).txt"
Merge-SPLogFile -StartTime $startTime -EndTime $endTime -Path $path -Overwrite

No comments:

Post a Comment