another technical blog...technically

Monday, December 8, 2014

A simple script to log to verbose mode

Hi, this will be a quick post, just to show you a little PowerShell script (yeah, lately i'm in love with PowerShell) could be very helpful during bug hunting sessions.
When you run the script, the log level is raised to Verbose and a new SPLog file is created for this verbose log.
When you press a key, the log level is resetted to the default one, and a new SPLog file is created, so the penultimate log file is the one you need to examine.
This is the script: enjoy
$ver = $host | select version
if ($ver.Version.Major -gt 1) {$host.Runspace.ThreadOptions = "ReuseThread"} 
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) 
{
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}

Write-Host "Setting TraceSeverity and EventSeverity to Verbose"
Set-SPLogLevel -TraceSeverity Verbose -EventSeverity Verbose

Write-Host "Creating a new Log file"
New-SPLogFile

Read-Host "Press ENTER key to reset default log level"

Write-Host "Resetting TraceSeverity and EventSeverity"
clear-sploglevel

Write-Host "Creating a new Log file for resetted log"
new-splogfile

Read-Host "Press any key to exit ..."
Or maybe download it from here.
Share:
written in: Milano, Italia

3 comments:

  1. It's difficult to find knowledgeable people for this subject, however, you seem like you
    know what you're talking about! Thanks

    ReplyDelete
  2. I think the admin of this web site is really working hard in support
    of his website, since here every information is quality based material.

    ReplyDelete
  3. I blog quite often and I genuinely thank you for your content.
    This article has really peaked my interest. I'm going to bookmark
    your site and keep checking for new details about once a week.
    I opted in for your Feed too.

    ReplyDelete

Because of a lot of SPAM about courses, I need to moderate all comments here.
I ensure you that I will answer whenever possible (if you are not a spammer).

Me, myself and I

My Photo
I'm just another IT guy sharing his knowledge with all of you out there.
Wanna know more?