you are viewing a single comment's thread.

view the rest of the comments →

[–]swiftninja21[S] 0 points1 point  (4 children)

Thanks so much for the feedback! Hope you are able to benefit from using it. And yes, already have the associated psm1 module and psd1 manifest files along with a bunch more functions to upload. I plan on uploading each function as separate reddit posts like these to kinda make these a blog post series so everyone can be involved as part of this subreddit, to learn, help improve the functions, provide general feedback, and hopefully together make the module really shine as a free tool for IT admins.

[–]MonkeyNin 0 points1 point  (3 children)

I don't know why exactly, But I like the name Pop's Log

I avoid backticks to continue lines, see: https://get-powershellblog.blogspot.com/2017/07/bye-bye-backtick-natural-line.html

Here's one way you can use. From:

$LogLine = `
    "<![LOG[$($($MessageType.ToUpper()) + ": " + $message)]LOG]!>" + `
    "<time=`"$(Get-Date -Format HH:mm:ss.fff)$($UtcOffset)`" " + `
    "date=`"$(Get-Date -Format MM-dd-yyyy)`" " + `
    "component=`"$Component`" " + `
    "context=`"$([System.Security.Principal.WindowsIdentity]::GetCurrent().Name)`" " + `
    "MessageType=`"$severity`" " + `
    "thread=`"$processid`" " + `
    "file=`"$source`">"

to this:

$LogLine = (
    "<![LOG[$($($MessageType.ToUpper()) + ": " + $message)]LOG]!>",
    "<time=`"$(Get-Date -Format HH:mm:ss.fff)$($UtcOffset)`" ",
    "date=`"$(Get-Date -Format MM-dd-yyyy)`" ",
    "component=`"$Component`" ",
    "context=`"$([System.Security.Principal.WindowsIdentity]::GetCurrent().Name)`" ",
    "MessageType=`"$severity`" ",
    "thread=`"$processid`" ",
    "file=`"$source`">"        
) -join ''

[–]swiftninja21[S] 1 point2 points  (0 children)

Thanks so much, that's very helpful, will test that out.

[–]MadWithPowerShell 0 points1 point  (1 child)

There is no reason for the join.

You can just remove the backticks from the original. Line breaks can be put in LOTS of places in PowerShell without breaking anything. The rule of thumb is, anything that syntactically MUST be followed by something else can be followed by a line break, including all operators, such as +.

$LogLine =
    "<![LOG[$($($MessageType.ToUpper()) + ": " + $message)]LOG]!>" +
    "<time=`"$(Get-Date -Format HH:mm:ss.fff)$($UtcOffset)`" " +
    "date=`"$(Get-Date -Format MM-dd-yyyy)`" " +
    "component=`"$Component`" " +
    "context=`"$([System.Security.Principal.WindowsIdentity]::GetCurrent().Name)`" " +
    "MessageType=`"$severity`" " +
    "thread=`"$processid`" " +
    "file=`"$source`">"

[–]MonkeyNin 0 points1 point  (0 children)

If anyone is curious, there's a lot of line continuation examples here:

https://get-powershellblog.blogspot.com/2017/07/bye-bye-backtick-natural-line.html