Upload ULS Logs to Doc Library - PowerShell

Document created by Eric Harris Employee on May 19, 2016Last modified by Eric Harris Employee on May 19, 2016
Version 2Show Document
  • View in full screen mode

This script can help you automate retrieving ULS logs and pushing them to a SharePoint Library.

 

AuthorAaron Labiosa
Long Description

The short description is simple enough :-)...

Dependencies

To use the script do the following:

  • Ensure you are running the PowerShell console as a SharePoint Administrative account.
  • Configure the URL of the site the ULS logs will be uploaded to (line 26).
  • Configure the StartTime and EndTime of the collection window (lines 12 and 14).
  • Configure the staging path where the log files will be kept prior to uploading (line 6).
  • Configure the destination Document Library for the ULS logs (line 16).
Support Info

Aaron Labiosa - Gather and upload SharePoint ULS to a Document Library with PowerShell

Compatibility

Nintex Workflow 2010

Nintex Workflow 2013

Platform

SharePoint Server 2010

SharePoint Server 2013

Screenshots
Add-PSSnapin Microsoft.SharePoint.PowerShell
[System.Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem')
$file = "logname"
$basePath = "C:\Logs"
$path = $($basePath + "\" + $file)
$zipPath = $($basePath + "\" + $file + ".zip")
$startTime = "01/01/1999 00:00"
$endTime = "01/01/1999 01:00"
$logLibraryName = 'ULS_Logs'
New-Item $path -ItemType directory
Merge-SPLogFile -Path $($path + "\" + "SPLogFile.log") -Overwrite -StartTime $startTime -EndTime $endTime
[System.IO.Compression.Zipfile]::CreateFromDirectory($path, $zipPath)
Remove-Item -Path $path -Recurse
$target = $(Get-SPWeb -Identity http://contoso.com).GetFolder($logLibraryName)
$stream = $(Get-Item $zipPath).OpenRead()
$target.Files.Add($($target.Url + "/") + $($file + ".zip"), $stream, $true)
$stream.Close()

Additional Information

For more information , check out the blog Gather and upload SharePoint ULS to a Document Library with PowerShell

Nintex Xchange Terms of Use Policy

Nintex makes no warranty or guarantee about the reliability, performance, quality, or functionality of any assets, and any assets you install are therefore provided as is. By downloading this asset, you agree to the terms of use.

1 person found this helpful

Attachments

Outcomes