Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Export event 307 to .csv (print server)

$
0
0

Hi there,

I'm starting to work with PS and I need some help.

I've found some scripts to export 307 event from print server but none is working for me.

When I run the code below, I got:

Get-WinEvent : No events were found that match the specified selection criteria.
At C:\Users\Administrator\Desktop\coco.ps1:5 char:12+ $Results = Get-WinEvent -FilterHashTable @{LogName="Microsoft-Windows-PrintServi ...+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo          : ObjectNotFound: (:) [Get-WinEvent], Exception+ FullyQualifiedErrorId : NoMatchingEventsFound,Microsoft.PowerShell.Commands.GetWinEventCommand

The script I was trying to run:

$aPrinterList = @()
$StartTime = "01/01/2014 12:00:01 PM"
$EndTime = "30/01/2014 6:00:01 PM"
$Results = Get-WinEvent -FilterHashTable @{LogName="Microsoft-Windows-PrintService/Operational"; ID=307; StartTime=$StartTime; EndTime=$EndTime;} -ComputerName "Planiserver01"
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:\PrintAudit.csv

Thanks in advance


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>