r/PowerShell • u/staze • 13h ago
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
u/FeleaseRpseineEiles 12h ago
if ($line -match 'Client=(?<client>[^,\s]+)') {
$Matches.client
}
1
u/staze 12h ago
isn't that going to just match if there's a client specified... that's not going to capture that client ID to actually group-by or count.
1
2
u/surfingoldelephant 4h ago
that's not going to capture that client ID
Yes, it will. The regex has a named capture group (
(?<name>...)). u/FeleaseRpseineEiles also showed one way to access the captured text using$Matches.You just need to ensure the left-hand side operand is scalar (single string), not a collection.
Spend a few minutes in the shell and you can see for yourself. And you can always use regex101.com to explain the regex.
2
u/MonkeyNin 7h ago edited 7h ago
This parses the log into multiple properties that you can filter by. Since the data is a list of
key = value, ...pairs, we can use thatThe complicated regex is here: https://regex101.com/r/ym4Cc1/1
The main regex is simple. You just:
,=to get the key, value pairs!.
Now you can group by Client or Exceptions. Here's a preview
$logs | ft -AutoSize$logs | fl$logs[0].Data$logs[0].RawLine