Windows Vista Forums
Vista Forums Home Join Vista Forums Webcasts Windows 7 Forum Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Calculate Printer Page Count Per User

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 07-09-2007   #1 (permalink)
Jeffrey Tadlock
Guest


 

Calculate Printer Page Count Per User

I have a script that pulls all print events from the main print server and
archive them. Now I would like to take those archives and come up with a
total page count for each user. Initially I am only looking to do this for
one particular printer.

I have a powershell function that returns the username and the page count
for that particular print job from the printer I want to report on. The
results look something like this:

domain\userone 2
domain\usertwo 3
domain\userone 21
domain\userthree 5
domain\usertwo 6
domain\userone 346

I can have the function return that comma separated if that will make things
easier.

Now in this same script I want to total the number of pages printed for each
user. Can someone point me in the right direction on how I should go about
summing the page count up for each user?

Thanks!
Jeffrey



My System SpecsSystem Spec
Old 07-09-2007   #2 (permalink)
forestial
Guest


 

RE: Calculate Printer Page Count Per User

If you have the raw data in a file called report.txt, then the following will
do the job:

$rep = gc report.txt
$totals = @{} #create a hash to hold totals
$rep | foreach-object {
($name, $pages) = $_.split(" "); #get the name and pagecount from one line
of file
($totals.$name) += [int]$pages #initialize or increment the total for the
hash entry keyed by $name
}
$totals # display the totals



"Jeffrey Tadlock" wrote:

> I have a script that pulls all print events from the main print server and
> archive them. Now I would like to take those archives and come up with a
> total page count for each user. Initially I am only looking to do this for
> one particular printer.
>
> I have a powershell function that returns the username and the page count
> for that particular print job from the printer I want to report on. The
> results look something like this:
>
> domain\userone 2
> domain\usertwo 3
> domain\userone 21
> domain\userthree 5
> domain\usertwo 6
> domain\userone 346
>
> I can have the function return that comma separated if that will make things
> easier.
>
> Now in this same script I want to total the number of pages printed for each
> user. Can someone point me in the right direction on how I should go about
> summing the page count up for each user?
>
> Thanks!
> Jeffrey
>
>
>

My System SpecsSystem Spec
Old 07-10-2007   #3 (permalink)
Jeffrey Tadlock
Guest


 

Re: Calculate Printer Page Count Per User


Thank you! This worked just as I needed. Your help is appreciated.

--Jeffrey

"forestial" <forestial@discussions.microsoft.com> wrote in message
news:6A87108F-904A-4445-A4BD-C59CAC976B33@microsoft.com...
> If you have the raw data in a file called report.txt, then the following
> will
> do the job:
>
> $rep = gc report.txt
> $totals = @{} #create a hash to hold totals
> $rep | foreach-object {
> ($name, $pages) = $_.split(" "); #get the name and pagecount from one
> line
> of file
> ($totals.$name) += [int]$pages #initialize or increment the total for
> the
> hash entry keyed by $name
> }
> $totals # display the totals
>
> "Jeffrey Tadlock" wrote:
>> I have a powershell function that returns the username and the page count
>> for that particular print job from the printer I want to report on. The
>> results look something like this:
>>
>> domain\userone 2
>> domain\usertwo 3
>> domain\userone 21
>> domain\userthree 5
>> domain\usertwo 6
>> domain\userone 346
>>
>> Now in this same script I want to total the number of pages printed for
>> each
>> user. Can someone point me in the right direction on how I should go
>> about
>> summing the page count up for each user?



My System SpecsSystem Spec
Old 07-10-2007   #4 (permalink)
Flowering Weeds
Guest


 

Re: Calculate Printer Page Count Per User


"Jeffrey Tadlock"

> and come up with a total page
> count for each user.


>
> domain\userone 2
> domain\usertwo 3
> domain\userone 21
> domain\userthree 5
> domain\usertwo 6
> domain\userone 346
>


Perhaps Microsoft's Log Parser 2.2

PS> LogParser.exe "SELECT field1 AS User, SUM(field2) AS
PageCountTotals FROM pa
geCount.txt GROUP BY
User" -i:tsv -headerRowff -iSeparator:"space" -statsff
User PageCountTotals
---------------- ---------------
domain\userone 369
domain\usertwo 9
domain\userthree 5
PS>

Oh and using a chart really
shows paper usage!

PS> LogParser.exe "SELECT field1 AS User, SUM(field2) AS
PageCountTotals INTO Pa
geCounts.gif FROM pageCount.txt GROUP BY
User" -i:tsv -headerRowff -iSeparator
:"space" -statsff -chartType:BarStacked3D -chartTitle:"Paper
Counts" -viewn
PS>

Log Parser works in most Windows
shells and Windows languages.

Just another way!




My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
vista print spooler and page count errors. OneTechForGOD Vista print fax & scan 3 03-26-2008 05:19 PM
Printer page counter needed Peter in New Zealand Vista General 4 11-14-2007 07:01 AM
User accounts not on log in page Singer712 Vista General 6 05-16-2007 08:58 AM
Cannot access printer via web page Disp350 Vista General 0 05-06-2007 04:55 PM
My printer prints only the top of the page. Mattesonjd Vista print fax & scan 0 02-24-2007 04:27 PM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51