'Powershell user printed pages report script returns an error
I'm trying to run this script in powershell but it is giving me this error. How can i resolve it ? Thanks !
$aPrinterList = @()
$StartTime = "22/04/2020 00:00:01 AM"
$EndTime = "23/04/2020 6:00:01 PM"
$Results = Get-WinEvent -FilterHashTable @{LogName="Print NORDIS-DC2/Operational";
ID=307; StartTime=$StartTime; EndTime=$EndTime;} -ComputerName "print-03"
ForEach($Result in $Results){
$ProperyData = [xml]$Result.ToXml()
$PrinterName = $ProperyData.Event.UserData.DocumentPrinted.Param5
If($PrinterName.Contains("Tehnic")){
$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
}
$aPrinterList | Export-Csv -LiteralPath C:\PrintServer\PrintAuditReport.csv
Get-WinEvent : The RPC server is unavailable At line:1 char:13
- $Results = Get-WinEvent -FilterHashTable @{LogName="Print NORDIS-DC2 ...
-
~~~~~~~~~~~~~~~~~~~- CategoryInfo : NotSpecified: (:) [Get-WinEvent], EventLogException
- FullyQualifiedErrorId : System.Diagnostics.Eventing.Reader.EventLogException,Microsoft.PowerShell.Commands.GetWi nEventCommand
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
