We are attempting to do an audit on printing, and thought that PowerShell would be an excellent way to parse the Event Viewers of our computers to get out all of our ID numbers 307 out of Microsoft-Windows-PrintServices/Operational. However I can not find a way to filter only these events out of the Get-WinEvent. I am very new to PowerShell, and any help in the right direction would be of great use.<\/p>","upvoteCount":8,"answerCount":18,"datePublished":"2014-07-24T18:37:57.000Z","author":{"@type":"Person","name":"kenwillen8812","url":"https://community.spiceworks.com/u/kenwillen8812"},"acceptedAnswer":{"@type":"Answer","text":"
This is from Example 15 from the help file:<\/p>\n
PS C:\\>$events = Get-WinEvent -FilterHashTable @{ LogName = \"Microsoft-Windows-Diagnostics-Performance/Operational\"; StartTime = $date; ID = 100 }\n<\/code><\/pre>\n
Seems like that would be the best way to go. To see the full help file:<\/p>\n
Get-Help Get-WinEvent -ShowWindow\n<\/code><\/pre>","upvoteCount":4,"datePublished":"2014-07-24T18:41:26.000Z","url":"https://community.spiceworks.com/t/how-to-powershell-get-winevent-by-eventid/324470/2","author":{"@type":"Person","name":"martin9700","url":"https://community.spiceworks.com/u/martin9700"}},"suggestedAnswer":[{"@type":"Answer","text":"We are attempting to do an audit on printing, and thought that PowerShell would be an excellent way to parse the Event Viewers of our computers to get out all of our ID numbers 307 out of Microsoft-Windows-PrintServices/Operational. However I can not find a way to filter only these events out of the Get-WinEvent. I am very new to PowerShell, and any help in the right direction would be of great use.<\/p>","upvoteCount":8,"datePublished":"2014-07-24T18:37:57.000Z","url":"https://community.spiceworks.com/t/how-to-powershell-get-winevent-by-eventid/324470/1","author":{"@type":"Person","name":"kenwillen8812","url":"https://community.spiceworks.com/u/kenwillen8812"}},{"@type":"Answer","text":"
Should be easy, this should work:<\/p>\n
Get-WinEvent -LogName \"Microsoft-Windows-PrintServices/Operational\" | Where-Object { $_.Id = 307 }\n<\/code><\/pre>","upvoteCount":2,"datePublished":"2014-07-24T18:41:34.000Z","url":"https://community.spiceworks.com/t/how-to-powershell-get-winevent-by-eventid/324470/3","author":{"@type":"Person","name":"chamele0n","url":"https://community.spiceworks.com/u/chamele0n"}},{"@type":"Answer","text":"help get-winevent -showwindow\n<\/code><\/pre>\n-------------------------- EXAMPLE 13 --------------------------<\/p>\n
PS C:>Get-WinEvent -Path “C:\\Tracing\\TraceLog.etl”, “c:\\Logs\\Windows PowerShell.evtx” -Oldest | Where-Object {$_.ID -eq “103”<\/strong>}<\/p>\nThis example shows how to get the events from an event trace log file (.etl) and from a copy of the Windows PowerShell log file (.evtx) that was saved to a test directory.<\/p>\n
You can combine multiple file types in a single command. Because the files contain the same type of .NET Framework object (an EventLogRecord object), you can use the same properties to filter them.<\/p>","upvoteCount":1,"datePublished":"2014-07-24T18:41:42.000Z","url":"https://community.spiceworks.com/t/how-to-powershell-get-winevent-by-eventid/324470/4","author":{"@type":"Person","name":"Little-Green-Man","url":"https://community.spiceworks.com/u/Little-Green-Man"}},{"@type":"Answer","text":"
Now what are the chances of that happening?<\/p>","upvoteCount":0,"datePublished":"2014-07-24T18:42:13.000Z","url":"https://community.spiceworks.com/t/how-to-powershell-get-winevent-by-eventid/324470/5","author":{"@type":"Person","name":"Little-Green-Man","url":"https://community.spiceworks.com/u/Little-Green-Man"}},{"@type":"Answer","text":"
Cham & Bill: Filter Left, Format Right<\/p>\n
<\/p>","upvoteCount":3,"datePublished":"2014-07-24T18:43:16.000Z","url":"https://community.spiceworks.com/t/how-to-powershell-get-winevent-by-eventid/324470/6","author":{"@type":"Person","name":"martin9700","url":"https://community.spiceworks.com/u/martin9700"}},{"@type":"Answer","text":"\n\n
<\/div>\n Bill Kindle:<\/div>\n
\nNow what are the chances of that happening?<\/p>\n<\/blockquote>\n<\/aside>\n
Beat you two by MOMENTS!<\/p>","upvoteCount":2,"datePublished":"2014-07-24T18:43:46.000Z","url":"https://community.spiceworks.com/t/how-to-powershell-get-winevent-by-eventid/324470/7","author":{"@type":"Person","name":"martin9700","url":"https://community.spiceworks.com/u/martin9700"}},{"@type":"Answer","text":"
Martin, when attempting to change those values, The logname and ID, to the desired log and event ID, it does not display anything. However, if I input<\/p>\n
(Get-WinEvent -computername mb-it-02 -ListProvider microsoft-windows-printservice).events | Format-Table ID, description -auto<\/p>\n
then I can clearly find IDs 307 in this log from my computer.<\/p>\n
Chamele0n, when attempting use this code, I just seem to get errors :<\/p>\n
PS C:> Get-WinEvent -LogName “Microsoft-Windows-PrintServices/Operational” | Where-Object { $_.Id = 307 }<\/p>\n
Get-WinEvent : There is not an event log on the localhost computer that matches “Microsoft-Windows-PrintServices/Operational”.<\/p>\n
At line:1 char:13<\/p>\n
Get-WinEvent <<<< -LogName “Microsoft-Windows-PrintServices/Operational” | Where-Object { $_.Id = 307 }<\/p>\n
CategoryInfo : ObjectNotFound: (Microsoft-Windo…ces/Operational:String) [Get-WinEvent], Exception<\/p>\n
FullyQualifiedErrorId : NoMatchingLogsFound,Microsoft.PowerShell.Commands.GetWinEventCommand<\/p>\n
PS C:> Get-WinEvent -listprovider “Microsoft-Windows-PrintServices/Operational” | Where-Object { $_.Id = 307 }<\/p>\n
Get-WinEvent : There is not an event provider on the localhost computer that matches “Microsoft-Windows-PrintServices/Operational”.<\/p>\n
At line:1 char:13<\/p>\n
Get-WinEvent <<<< -listprovider “Microsoft-Windows-PrintServices/Operational” | Where-Object { $_.Id = 307 }<\/p>\n
CategoryInfo : ObjectNotFound: ( [Get-WinEvent], Exception<\/p>\n
FullyQualifiedErrorId : NoMatchingProvidersFound,Microsoft.PowerShell.Commands.GetWinEventCommand%uFEFF<\/p>\n
Bill, I have not tried your method yet.<\/p>","upvoteCount":0,"datePublished":"2014-07-24T18:53:46.000Z","url":"https://community.spiceworks.com/t/how-to-powershell-get-winevent-by-eventid/324470/8","author":{"@type":"Person","name":"kenwillen8812","url":"https://community.spiceworks.com/u/kenwillen8812"}},{"@type":"Answer","text":"\n\n
<\/div>\n Bill Kindle:<\/div>\n
\nhelp get-winevent -showwindow\n<\/code><\/pre>\n-------------------------- EXAMPLE 13 --------------------------<\/p>\n
PS C:>Get-WinEvent -Path “C:\\Tracing\\TraceLog.etl”, “c:\\Logs\\Windows PowerShell.evtx” -Oldest | Where-Object {$_.ID -eq “103”<\/strong>}<\/p>\nThis example shows how to get the events from an event trace log file (.etl) and from a copy of the Windows PowerShell log file (.evtx) that was saved to a test directory.<\/p>\n
You can combine multiple file types in a single command. Because the files contain the same type of .NET Framework object (an EventLogRecord object), you can use the same properties to filter them.<\/p>\n<\/blockquote>\n<\/aside>\n
Bill, I’m not certain how they are finding the paths here. Should this be something that I am exporting? And is the combination to the PowerShell log file only so that you can at that point use the “Where-Object” command?<\/p>","upvoteCount":0,"datePublished":"2014-07-24T19:30:09.000Z","url":"https://community.spiceworks.com/t/how-to-powershell-get-winevent-by-eventid/324470/9","author":{"@type":"Person","name":"kenwillen8812","url":"https://community.spiceworks.com/u/kenwillen8812"}},{"@type":"Answer","text":"\n\n
<\/div>\n
Martin9700:<\/div>\n
\nThis is from Example 15 from the help file:<\/p>\n
PS C:\\>$events = Get-WinEvent -FilterHashTable @{ LogName = \"Microsoft-Windows-Diagnostics-Performance/Operational\"; StartTime = $date; ID = 100 }\n<\/code><\/pre>\nSeems like that would be the best way to go. To see the full help file:<\/p>\n
Get-Help Get-WinEvent -ShowWindow\n<\/code><\/pre>\n<\/blockquote>\n<\/aside>\nOkay, so after trying this again, it did seem to work for me, however I removed the start time and just grabbed the IDs. Thanks Martin!<\/p>","upvoteCount":2,"datePublished":"2014-07-25T17:30:13.000Z","url":"https://community.spiceworks.com/t/how-to-powershell-get-winevent-by-eventid/324470/10","author":{"@type":"Person","name":"kenwillen8812","url":"https://community.spiceworks.com/u/kenwillen8812"}},{"@type":"Answer","text":"
Welcome, sorry I could jump in, busy at work <\/p>","upvoteCount":0,"datePublished":"2014-07-25T17:55:24.000Z","url":"https://community.spiceworks.com/t/how-to-powershell-get-winevent-by-eventid/324470/11","author":{"@type":"Person","name":"martin9700","url":"https://community.spiceworks.com/u/martin9700"}},{"@type":"Answer","text":"\n\n
<\/div>\n
Martin9700:<\/div>\n
\nWelcome, sorry I could jump in, busy at work <\/p>\n<\/blockquote>\n<\/aside>\n
No problem. Out of curiosity, do you happen to have any ideas about extending this to run on a list of computers? We’ve managed to get everything working out now on local and remote computers. However, if I attempt to use a variable, for example<\/p>\n
PS C:\\> $pods = \"Computer1\",\"Computer2\",\"Computer3\"\nPS C:\\> foreach ($pod in $pods)\n>> {Get-WinEvent -ComputerName \"$pods\" -FilterHashTable @{ LogName = \"Microsoft-Windows-PrintService/Operational\" ; ID = \"307\"} | format-table id, message, machinename -auto >> \"C:\\PS Test\\Test Log.txt\"}\n<\/code><\/pre>\nWe get back<\/p>\n
Get-WinEvent : The RPC server is unavailable\nAt line:2 char:14\n+ {Get-WinEvent <<<< -ComputerName \"$pods\" -FilterHashTable @{ LogName = \"Microsoft-Windows-PrintService/Operational\" ; ID = \"307\"} | format-table id, message, machinename -auto >> \"C:\\PS Test\\Test Log.txt\"}\n + CategoryInfo : NotSpecified: (:) [Get-WinEvent], EventLogException\n + FullyQualifiedErrorId : System.Diagnostics.Eventing.Reader.EventLogException,Microsoft.PowerShell.Commands.GetWinEventCommand\n\n<\/code><\/pre>\nFor each computer. However, when we run the command without the variable and variable list it reports back the list of events.<\/p>","upvoteCount":0,"datePublished":"2014-07-25T18:42:01.000Z","url":"https://community.spiceworks.com/t/how-to-powershell-get-winevent-by-eventid/324470/12","author":{"@type":"Person","name":"kenwillen8812","url":"https://community.spiceworks.com/u/kenwillen8812"}},{"@type":"Answer","text":"
Firstly, in your Get-WinEvent call, change $pods to $pod.<\/p>\n
Next, turn on verbose output ($VerbosePreference = “Continue”). Then put a Write-Verbose statement in your code.<\/p>\n
$pods = \"mccoyb01\",\"mccoyb02\"\nforeach ($pod in $pods) {\n Write-Verbose \"Testing $pod\"\n Get-WinEvent -ComputerName $pod -FilterHashTable @{ LogName = \"Microsoft-Windows-Diagnostics-Performance/Operational\"; ID = 100\n \n} | format-table id, message, machinename -auto >> \"C:\\PS Test\\Test Log.txt\"}\n<\/code><\/pre>\nThis uses the sample event. Modify to test your event ID 307.<\/p>","upvoteCount":3,"datePublished":"2014-07-25T19:31:30.000Z","url":"https://community.spiceworks.com/t/how-to-powershell-get-winevent-by-eventid/324470/13","author":{"@type":"Person","name":"bobmccoy","url":"https://community.spiceworks.com/u/bobmccoy"}},{"@type":"Answer","text":"\n\n
<\/div>\n
bobmccoy:<\/div>\n
\nFirstly, in your Get-WinEvent call, change $pods to $pod.<\/p>\n
Next, turn on verbose output ($VerbosePreference = “Continue”). Then put a Write-Verbose statement in your code.<\/p>\n
$pods = \"mccoyb01\",\"mccoyb02\"\nforeach ($pod in $pods) {\n Write-Verbose \"Testing $pod\"\n Get-WinEvent -ComputerName $pod -FilterHashTable @{ LogName = \"Microsoft-Windows-Diagnostics-Performance/Operational\"; ID = 100\n \n} | format-table id, message, machinename -auto >> \"C:\\PS Test\\Test Log.txt\"}\n<\/code><\/pre>\nThis uses the sample event. Modify to test your event ID 307.<\/p>\n<\/blockquote>\n<\/aside>\n
Thanks Bob! This seems to be working out perfectly.<\/p>","upvoteCount":0,"datePublished":"2014-07-28T11:24:36.000Z","url":"https://community.spiceworks.com/t/how-to-powershell-get-winevent-by-eventid/324470/14","author":{"@type":"Person","name":"kenwillen8812","url":"https://community.spiceworks.com/u/kenwillen8812"}},{"@type":"Answer","text":"
Thanks Ken. Since Martin already has Best Answer, it you would mark my reply above as a Helpful Answer, I would appreciate it.<\/p>","upvoteCount":0,"datePublished":"2014-07-28T12:15:58.000Z","url":"https://community.spiceworks.com/t/how-to-powershell-get-winevent-by-eventid/324470/15","author":{"@type":"Person","name":"bobmccoy","url":"https://community.spiceworks.com/u/bobmccoy"}},{"@type":"Answer","text":"
Note: -FilterHashTable does not work if the server is Windows 2008 (not R2). You will get a “parameter is incorrect” error.<\/p>\n
Found this to be true on Powershell 2.0 and 3.0 so far - Where-Object is a lot slower but works.<\/p>","upvoteCount":0,"datePublished":"2014-10-13T15:22:00.000Z","url":"https://community.spiceworks.com/t/how-to-powershell-get-winevent-by-eventid/324470/16","author":{"@type":"Person","name":"barrypatterson4732","url":"https://community.spiceworks.com/u/barrypatterson4732"}},{"@type":"Answer","text":"\n\n
<\/div>\n
Magefyre:<\/div>\n
\nNote: -FilterHashTable does not work if the server is Windows 2008 (not R2). You will get a “parameter is incorrect” error.<\/p>\n
Found this to be true on Powershell 2.0 and 3.0 so far - Where-Object is a lot slower but works.<\/p>\n<\/blockquote>\n<\/aside>\n
Thanks for the update on this. Luckily the computers I was doing this for were all Windows 7. I’ve even managed to fiddle with this script and even get it printing out to a CSV for easier parsing.<\/p>","upvoteCount":1,"datePublished":"2014-11-10T16:28:43.000Z","url":"https://community.spiceworks.com/t/how-to-powershell-get-winevent-by-eventid/324470/17","author":{"@type":"Person","name":"kenwillen8812","url":"https://community.spiceworks.com/u/kenwillen8812"}},{"@type":"Answer","text":"
$pclist = (get-content \"\\\\somepath\\to\\somepclistfile.txt\")\nforeach ($pc in $pclist) {\n Write-Verbose \"Testing $pc\"\n Get-WinEvent -ComputerName $pc -FilterHashTable @{ LogName = \"Microsoft-Windows-PrintService/Operational\"; ID = 307\n} | Export-CSV -Append -Path \"\\\\somepath\\to\\output.csv\" -Encoding Ascii -NoTypeInformation}\n<\/code><\/pre>\nRoughly this is the updated version of the code that was worked out here. Worked beautifully as a way to audit print jobs per computer.<\/p>","upvoteCount":1,"datePublished":"2014-11-10T17:32:55.000Z","url":"https://community.spiceworks.com/t/how-to-powershell-get-winevent-by-eventid/324470/18","author":{"@type":"Person","name":"kenwillen8812","url":"https://community.spiceworks.com/u/kenwillen8812"}}]}}
We are attempting to do an audit on printing, and thought that PowerShell would be an excellent way to parse the Event Viewers of our computers to get out all of our ID numbers 307 out of Microsoft-Windows-PrintServices/Operational. However I can not find a way to filter only these events out of the Get-WinEvent. I am very new to PowerShell, and any help in the right direction would be of great use.
8 Spice ups
This is from Example 15 from the help file:
PS C:\>$events = Get-WinEvent -FilterHashTable @{ LogName = "Microsoft-Windows-Diagnostics-Performance/Operational"; StartTime = $date; ID = 100 }
Seems like that would be the best way to go. To see the full help file:
Get-Help Get-WinEvent -ShowWindow
4 Spice ups
chamele0n
(Chamele0n)
July 24, 2014, 6:41pm
3
Should be easy, this should work:
Get-WinEvent -LogName "Microsoft-Windows-PrintServices/Operational" | Where-Object { $_.Id = 307 }
2 Spice ups
help get-winevent -showwindow
-------------------------- EXAMPLE 13 --------------------------
PS C:>Get-WinEvent -Path “C:\Tracing\TraceLog.etl”, “c:\Logs\Windows PowerShell.evtx” -Oldest | Where-Object {$_.ID -eq “103” }
This example shows how to get the events from an event trace log file (.etl) and from a copy of the Windows PowerShell log file (.evtx) that was saved to a test directory.
You can combine multiple file types in a single command. Because the files contain the same type of .NET Framework object (an EventLogRecord object), you can use the same properties to filter them.
1 Spice up
Now what are the chances of that happening?
Cham & Bill: Filter Left, Format Right
3 Spice ups
Martin, when attempting to change those values, The logname and ID, to the desired log and event ID, it does not display anything. However, if I input
(Get-WinEvent -computername mb-it-02 -ListProvider microsoft-windows-printservice).events | Format-Table ID, description -auto
then I can clearly find IDs 307 in this log from my computer.
Chamele0n, when attempting use this code, I just seem to get errors :
PS C:> Get-WinEvent -LogName “Microsoft-Windows-PrintServices/Operational” | Where-Object { $_.Id = 307 }
Get-WinEvent : There is not an event log on the localhost computer that matches “Microsoft-Windows-PrintServices/Operational”.
At line:1 char:13
Get-WinEvent <<<< -LogName “Microsoft-Windows-PrintServices/Operational” | Where-Object { $_.Id = 307 }
CategoryInfo : ObjectNotFound: (Microsoft-Windo…ces/Operational:String) [Get-WinEvent], Exception
FullyQualifiedErrorId : NoMatchingLogsFound,Microsoft.PowerShell.Commands.GetWinEventCommand
PS C:> Get-WinEvent -listprovider “Microsoft-Windows-PrintServices/Operational” | Where-Object { $_.Id = 307 }
Get-WinEvent : There is not an event provider on the localhost computer that matches “Microsoft-Windows-PrintServices/Operational”.
At line:1 char:13
Get-WinEvent <<<< -listprovider “Microsoft-Windows-PrintServices/Operational” | Where-Object { $_.Id = 307 }
CategoryInfo : ObjectNotFound: ( [Get-WinEvent], Exception
FullyQualifiedErrorId : NoMatchingProvidersFound,Microsoft.PowerShell.Commands.GetWinEventCommand%uFEFF
Bill, I have not tried your method yet.
help get-winevent -showwindow
-------------------------- EXAMPLE 13 --------------------------
PS C:>Get-WinEvent -Path “C:\Tracing\TraceLog.etl”, “c:\Logs\Windows PowerShell.evtx” -Oldest | Where-Object {$_.ID -eq “103” }
This example shows how to get the events from an event trace log file (.etl) and from a copy of the Windows PowerShell log file (.evtx) that was saved to a test directory.
You can combine multiple file types in a single command. Because the files contain the same type of .NET Framework object (an EventLogRecord object), you can use the same properties to filter them.
Bill, I’m not certain how they are finding the paths here. Should this be something that I am exporting? And is the combination to the PowerShell log file only so that you can at that point use the “Where-Object” command?
Martin9700:
This is from Example 15 from the help file:
PS C:\>$events = Get-WinEvent -FilterHashTable @{ LogName = "Microsoft-Windows-Diagnostics-Performance/Operational"; StartTime = $date; ID = 100 }
Seems like that would be the best way to go. To see the full help file:
Get-Help Get-WinEvent -ShowWindow
Okay, so after trying this again, it did seem to work for me, however I removed the start time and just grabbed the IDs. Thanks Martin!
2 Spice ups
Welcome, sorry I could jump in, busy at work
No problem. Out of curiosity, do you happen to have any ideas about extending this to run on a list of computers? We’ve managed to get everything working out now on local and remote computers. However, if I attempt to use a variable, for example
PS C:\> $pods = "Computer1","Computer2","Computer3"
PS C:\> foreach ($pod in $pods)
>> {Get-WinEvent -ComputerName "$pods" -FilterHashTable @{ LogName = "Microsoft-Windows-PrintService/Operational" ; ID = "307"} | format-table id, message, machinename -auto >> "C:\PS Test\Test Log.txt"}
We get back
Get-WinEvent : The RPC server is unavailable
At line:2 char:14
+ {Get-WinEvent <<<< -ComputerName "$pods" -FilterHashTable @{ LogName = "Microsoft-Windows-PrintService/Operational" ; ID = "307"} | format-table id, message, machinename -auto >> "C:\PS Test\Test Log.txt"}
+ CategoryInfo : NotSpecified: (:) [Get-WinEvent], EventLogException
+ FullyQualifiedErrorId : System.Diagnostics.Eventing.Reader.EventLogException,Microsoft.PowerShell.Commands.GetWinEventCommand
For each computer. However, when we run the command without the variable and variable list it reports back the list of events.
bobmccoy
(bobmccoy)
July 25, 2014, 7:31pm
13
Firstly, in your Get-WinEvent call, change $pods to $pod.
Next, turn on verbose output ($VerbosePreference = “Continue”). Then put a Write-Verbose statement in your code.
$pods = "mccoyb01","mccoyb02"
foreach ($pod in $pods) {
Write-Verbose "Testing $pod"
Get-WinEvent -ComputerName $pod -FilterHashTable @{ LogName = "Microsoft-Windows-Diagnostics-Performance/Operational"; ID = 100
} | format-table id, message, machinename -auto >> "C:\PS Test\Test Log.txt"}
This uses the sample event. Modify to test your event ID 307.
3 Spice ups
bobmccoy:
Firstly, in your Get-WinEvent call, change $pods to $pod.
Next, turn on verbose output ($VerbosePreference = “Continue”). Then put a Write-Verbose statement in your code.
$pods = "mccoyb01","mccoyb02"
foreach ($pod in $pods) {
Write-Verbose "Testing $pod"
Get-WinEvent -ComputerName $pod -FilterHashTable @{ LogName = "Microsoft-Windows-Diagnostics-Performance/Operational"; ID = 100
} | format-table id, message, machinename -auto >> "C:\PS Test\Test Log.txt"}
This uses the sample event. Modify to test your event ID 307.
Thanks Bob! This seems to be working out perfectly.
bobmccoy
(bobmccoy)
July 28, 2014, 12:15pm
15
Thanks Ken. Since Martin already has Best Answer, it you would mark my reply above as a Helpful Answer, I would appreciate it.
Note: -FilterHashTable does not work if the server is Windows 2008 (not R2). You will get a “parameter is incorrect” error.
Found this to be true on Powershell 2.0 and 3.0 so far - Where-Object is a lot slower but works.
Magefyre:
Note: -FilterHashTable does not work if the server is Windows 2008 (not R2). You will get a “parameter is incorrect” error.
Found this to be true on Powershell 2.0 and 3.0 so far - Where-Object is a lot slower but works.
Thanks for the update on this. Luckily the computers I was doing this for were all Windows 7. I’ve even managed to fiddle with this script and even get it printing out to a CSV for easier parsing.
1 Spice up
$pclist = (get-content "\\somepath\to\somepclistfile.txt")
foreach ($pc in $pclist) {
Write-Verbose "Testing $pc"
Get-WinEvent -ComputerName $pc -FilterHashTable @{ LogName = "Microsoft-Windows-PrintService/Operational"; ID = 307
} | Export-CSV -Append -Path "\\somepath\to\output.csv" -Encoding Ascii -NoTypeInformation}
Roughly this is the updated version of the code that was worked out here. Worked beautifully as a way to audit print jobs per computer.
1 Spice up