Hey
I got this script...
$printserver = printserver01 #define printserver $d = gwmi win32_printjob -comp $printserver -cred $cred #get printjobs from the server $d | select name, document #select name and document Foreach ($_ in $d) #foreach printque, remove everything after the comma { $_.name.substring(0,$_.name.lastindexof(',')) }
It is supposed to list printques name and documents in que.. The printques name is something like this "printerque1, 439" so I want to remove everything after the comma so the output becomes "printerque1". This works fine.
What doesn't work is listing both name and document in the output. I've tried putting the
select name, document part in different places in the script, but the output becomes something like this;
name document
printerque1, 439 something
printerque1
If I move the select name, document part I can get this output:
printerque1
With no headers or documents.
Please help this noobie :)
UPDATED: This worked perfectly, thank you Kazun.
$printserver = printserver01 #define printserver
$d = gwmi win32_printjob -comp $printserver -cred $cred
$d | select @{n="name";e={$_.name.substring(0,$_.name.lastindexof(','))}}, document -excl name