Change the SharePoint ULS Log File Path From a Script

PowerShell script that will move the SharePoint log files and set the retention of the log files.

To run this script you will need to set the PowerShell execution policy using the following PowerShell command:

set-executionpolicy Unrestricted

Copy the following code and paste it into a PowerShell script file like SetSPLog.ps1. To call this from the command line or within a command script file use the following syntax:

This will move the log files to D:\Logs\SharePoint, keeping 96 files that have 30 minutes of logs in each file.

powershell.exe “& .\SetSPLog.ps1 ‘D:\Logs\SharePoint’ 96 30”

PowerShell Code (SetSPLog.ps1)

if ($args.length -lt 3) {write-warning "Syntax: SetSPLog.ps1 [Location]
[Logs to Keep] [Log Interval]"; break} [System.Reflection.Assembly]::

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: