公司的管理需求就是查看哪个员工打印的情况,解决方案:

第一,到Windows那台打印服务器,把打印日志启动。操作方法就是,打开Event Viewer,然后导航到Applications and Services Logs\Microsoft\windows\Print Service\Optional

在这个上面点右键,选择Enabled Log


wKiom1m7aAiQBf62AAEmpmS_j5E440.jpg


以上方法也可以通过Powershell语句来实现。


Get-WinEvent -ListLog Microsoft-Windows-PrintService/Operational -OutVariable PrinterLog |

Select-Object -Property LogName, IsClassicLog, IsEnabled

 

$PrinterLog.set_IsEnabled($true)

 

$PrinterLog.SaveChanges()

 

Get-WinEvent -ListLog Microsoft-Windows-PrintService/Operational -OutVariable PrinterLog |

Select-Object -Property LogName, IsClassicLog, IsEnabled


wKioL1m7aQOyEbyvAAF8RW2Fac8755.jpg

先运行第一条命令,发现那个属性值未被启用,然后通过命令强制启用,再检查一下。



以下通过这个命令就能一下子得到答案。

Get-WinEvent -FilterHashTable @{LogName="Microsoft-Windows-PrintService/Operational"; ID=307; StartTime=(Get-Date).AddDays(-1)} |
Format-Table -Property TimeCreated,
                        @{label='UserName';expression={$_.properties[2].value}},
                        @{label='ComputerName';expression={$_.properties[3].value}},
                        @{label='PrinterName';expression={$_.properties[4].value}},
                        @{label='PrintSize';expression={$_.properties[6].value}},
                        @{label='Pages';expression={$_.properties[7].value}}