Reporting on printer usage
Knowing who is using your printing devices and how much can be important in terms of capacity planning.
By default, Windows does not log printer usage information. But it is simple to turn on this logging and use the results.
Getting ready
You use this recipe on the PSRV
host.
How to do it...
- Run
wevtutil.exe
to turn on printer monitoring on thePSRV
host:$LogName = 'Microsoft-Windows-PrintService/Operational' wevtutil.exe sl $LogName /enabled:true
- Define a function that returns objects for each printer job completed on the server:
Function Get-PrinterUsage { # 2.1 Get events from the print server event log $LogName = 'Microsoft-Windows-PrintService/Operational' $Dps = Get-WinEvent -LogName $LogName | Where-Object ID -eq 307 Foreach ($Dp in $Dps) { # 2.2 Create an ordered hash table $Document = [ordered] @{} # 2.3 Populate the hash table with properties from the # Event Log entry $Document.Id = $Dp.Properties[0].value...