欢迎光临
我们一直在努力

使用Powershell 统计Widnows打印服务器用户打印数量

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

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

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

以上方法也可以通过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

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

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

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}}

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。