Answer the question
In order to leave comments, you need to log in
How to pass a value with "\\" characters to Get-Counter?
I am writing a script for accounting for printed pages:
$date = get-date -format dd-MM-yyyy
$printername = Get-Printer | select -expand Name
foreach ($printer in $printername) {
$number = Get-Counter "\Очередь печати($printer)\Всего напечатано страниц" | Foreach-Object {$_.CounterSamples[0].CookedValue}
Convertto-html -title "Статистика печати" -PreContent "Количество распечатанных листов на $printer за $date : <b>$number</b>" >> e:\counter_print_pages.html}
Get-Counter : Invalid performance counter path \Print Queue(\\192.168.1.13\HP LaserJet P2035)\Total Pages Printed.
E:\pagecount.ps1:4 char:11
+ $number = Get-Counter "\Print Queue($printer)\Total Pages Printed ...
+ ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (: ) [Get-Counter], Exception
+ FullyQualifiedErrorId : CounterPathIsInvalid,Microsoft.PowerShell.Commands.GetCounterCommand
Number of sheets printed on Fax for 19-11-2019 : 0
Number of sheets printed on Adobe PDF for 19-11-2019 : 0
Number of sheets printed on \\192.168.1.13\HP LaserJet P2035 for 19-11-2019 :
Answer the question
In order to leave comments, you need to log in
I may be wrong, but the system does not have counters for printers connected not locally, but over the network. You can verify this by opening the Performance monitor and looking at the list of devices in the Print Queue category.
I think you need to upload information about the number of printed pages on the PC / server from which this printer is shared.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question