Travis Lingenfelder Archive

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

Use a Settings File for Your PowerShell Scripts

When developing scripts (and almost anything else) I prefer to hard-code any settings thay may need to be changed later.  One method that I employ while writing PowerShell scripts is the use of a settings.ini file.  In this file I can place any configuration information and when I need to change a setting or run the script against another environment I only need to modify a single file. Within the file I can group thing logically and assign simple values that can be used within the scripts.  When the PowerShell script runs, it will read the contents of the settings.ini