r/PowerShell • • Sep 10 '26

Question Parse SoftwareDistrubtion.log for Client ID's

Troubleshooting some issues with WSUS, and wondering if anyone has a Powershell script already for parsing the SoftwareDistribution.log to get count of Clients.

Example line:
2026-09-10 18:36:13.084 UTC Warning w3wp.334 SoapUtilities.CreateException ThrowException: actor = http://server.example.com:8530/CLIENTWEBSERVICE/client.asmx, ID=94d8e636-29bc-4bc8-8958-79e5e189455e, ErrorCode=InvalidParameters, Message=parameters.OtherCachedUpdateIDs, Client=13ef38ff-b877-4d9a-9b1e-cf190d8fc801

Hopefully I could just extract the Client and then group/count on that. Trying to figure out how many machines are having this issue.

Thanks!

2 Upvotes

6 comments sorted by

View all comments

Show parent comment

2

u/PinchesTheCrab Sep 21 '26

I'd be tempted to move most of the logic into a switch since the pattern is doing the heavy lifting:

$logLines = @( '2026-09-10 18:36:13.084 UTC Warning w3wp.334 SoapUtilities.CreateException ThrowException: actor = http://server.example.com:8530/CLIENTWEBSERVICE/client.asmx, ID=94d8e636-29bc-4bc8-8958-79e5e189455e, ErrorCode=InvalidParameters, Message=parameters.OtherCachedUpdateIDs, Client=13ef38ff-b877-4d9a-9b1e-cf190d8fc801' )

# $logs = switch -regex -file ('sccmlogfile.log')
$logs = switch -regex ( $logLines ) {
    $regex {
        $props = [ordered]@{}
        $matches.Pairs -split '\s*,\s*' | ForEach-Object {
            $key, $value = $_ -split '\s*=\s*', 2
            $props[ $key ] = $value
        }

        [pscustomobject]@{
            Error     = $props.ErrorCode
            Message   = $props.Message
            Actor     = $props.Actor
            Client    = $props.Client
            Date      = $Found.DateTime
            Severity  = $Found.Severity
            Exception = $Found.Exception
            RawLine   = $Line
            Data      = $Data
        }
    }
}

$logs | Format-Table -AutoSize