Last active
December 13, 2021 14:15
-
-
Save 9to5IT/9619820 to your computer and use it in GitHub Desktop.
PowerShell: Get list of printed documents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$aPrinterList = @() | |
$StartTime = "11/01/2013 12:00:01 PM" | |
$EndTime = "11/01/2013 6:00:01 PM" | |
$Results = Get-WinEvent -FilterHashTable @{LogName="Microsoft-Windows-PrintService/Operational"; ID=307; StartTime=$StartTime; EndTime=$EndTime;} -ComputerName "print-01" | |
ForEach($Result in $Results){ | |
$ProperyData = [xml]$Result.ToXml() | |
$PrinterName = $ProperyData.Event.UserData.DocumentPrinted.Param5 | |
If($PrinterName.Contains("HP-4350-01")){ | |
$hItemDetails = New-Object -TypeName psobject -Property @{ | |
DocName = $ProperyData.Event.UserData.DocumentPrinted.Param2 | |
UserName = $ProperyData.Event.UserData.DocumentPrinted.Param3 | |
MachineName = $ProperyData.Event.UserData.DocumentPrinted.Param4 | |
PrinterName = $PrinterName | |
PageCount = $ProperyData.Event.UserData.DocumentPrinted.Param8 | |
TimeCreated = $Result.TimeCreated | |
} | |
$aPrinterList += $hItemDetails | |
} | |
} | |
#Output results to CSV file | |
$aPrinterList | Export-Csv -LiteralPath C:\Temp\PrintAudit.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment