Windows Vista Forums
Vista Forums Home Join Vista Forums Donate 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

Term Server Printing

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 07-10-2007   #1 (permalink)
Bryce Ingalls
Guest


 

Term Server Printing

Hi all--

I have a client running a Window 2003 Terminal Server. One of the apps
running on the server requires printing to LPT2. I need to write a script
that will perform the following:

1. Determine the default printer (as setup by the term serv)
2. Share the default printer using a standard naming convention
3. Map LPT2 to the newly-created share name (similar to net use lpt2:
\\server\share)

I am a complete scripting novice and have decided that rather than "go back"
to VBScript / WSH, I should start out of the gate using PowerShell.
Questions:

1. Am I right in going the PowerShell route? I have seen Claudio
Rodriguez' TS Kixstart script for accomplishing a very similar task. How
about WSH/VBScript??
2. Of the books available on the market, any recommendations?

Thanks,

Bryce



My System SpecsSystem Spec
Old 07-10-2007   #2 (permalink)
Hal Rottenberg
Guest


 

Re: Term Server Printing

(i'm replying twice, ones for your code question and once for the meta-
discussion.)

> 1. Am I right in going the PowerShell route?


IMHO think your time would be better spent learning PSH rather than
VBscript. As to whether powershell is most suited to this particular
problem, this is somewhat close to a login script discussion held here
recently:

http://groups.google.com/group/micro...679e541c3125cf

Read that for some thoughts on using psh as a login script.

> 2. Of the books available on the market, any recommendations?


I am reading "Powershell in Action" and enjoying it.

My System SpecsSystem Spec
Old 07-10-2007   #3 (permalink)
Hal Rottenberg
Guest


 

Re: Term Server Printing

On Jul 10, 12:25 pm, "Bryce Ingalls" <b...@nospam.com> wrote:
> 1. Determine the default printer (as setup by the term serv)
> 2. Share the default printer using a standard naming convention
> 3. Map LPT2 to the newly-created share name (similar to net use lpt2:
> \\server\share)


I'll let someone else put this together into a script, but here's how
you find this sort of info out:

28# $a = Get-WmiObject Win32_Printer
29# $a | get-member


TypeName: System.Management.ManagementObject#root
\cimv2\Win32_Printer

Name MemberType Definition
---- ---------- ----------
CancelAllJobs Method
System.Management.ManagementBaseObject CancelAllJobs()
Pause Method
System.Management.ManagementBaseObject Pause()
PrintTestPage Method
System.Management.ManagementBaseObject PrintTestPage()
....

30# $a.GetType()

IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[]
System.Array

It's an array, and they are indexed by brackets, starting at 0. e.g.
$a[0].

Just typing $a at a prompt will list them, or you can pipe it through
format-list or format-table.

Here you can see I have 4 printers installed:

39# $a | Format-Table

Location Name PrinterState
PrinterStatus ShareName SystemName
-------- ---- ------------
------------- --------- ----------
Microsoft XPS D...
0 3 ATLLAPHROTTENBE
CutePDF Writer
0 3 ATLLAPHROTTENBE
Building B 5th ... \\atla-prnt01\B...
0 3 B5-Canon01 \\atla-prnt01
Bldg B 5th Floo... \\atla-prnt01\B...
0 3 B5-Canon02 \\atla-prnt01

Let's see what happens if I examine the Default property (which you'll
see in the Get-Member statement above if you run it) of the 3rd
printer, again remembering arrays start at 0.

38# $a[2].Default
True

That's the default printer. How to find the share name?

44# $prnPath = $a[2].Name
45# $prnPath
\\atla-prnt01\B5-Canon01

Then a "net use lpt2: $prnPath" would finish the mapping.

HTH

My System SpecsSystem Spec
Old 07-11-2007   #4 (permalink)
Bryce Ingalls
Guest


 

Re: Term Server Printing

Thanks for the script example and book recommendation. Will give this a
whirl...

Bryce

"Hal Rottenberg" <halr9000@gmail.com> wrote in message
news:1184086703.515874.203530@o61g2000hsh.googlegroups.com...
> On Jul 10, 12:25 pm, "Bryce Ingalls" <b...@nospam.com> wrote:
>> 1. Determine the default printer (as setup by the term serv)
>> 2. Share the default printer using a standard naming convention
>> 3. Map LPT2 to the newly-created share name (similar to net use lpt2:
>> \\server\share)

>
> I'll let someone else put this together into a script, but here's how
> you find this sort of info out:
>
> 28# $a = Get-WmiObject Win32_Printer
> 29# $a | get-member
>
>
> TypeName: System.Management.ManagementObject#root
> \cimv2\Win32_Printer
>
> Name MemberType Definition
> ---- ---------- ----------
> CancelAllJobs Method
> System.Management.ManagementBaseObject CancelAllJobs()
> Pause Method
> System.Management.ManagementBaseObject Pause()
> PrintTestPage Method
> System.Management.ManagementBaseObject PrintTestPage()
> ...
>
> 30# $a.GetType()
>
> IsPublic IsSerial Name BaseType
> -------- -------- ---- --------
> True True Object[]
> System.Array
>
> It's an array, and they are indexed by brackets, starting at 0. e.g.
> $a[0].
>
> Just typing $a at a prompt will list them, or you can pipe it through
> format-list or format-table.
>
> Here you can see I have 4 printers installed:
>
> 39# $a | Format-Table
>
> Location Name PrinterState
> PrinterStatus ShareName SystemName
> -------- ---- ------------
> ------------- --------- ----------
> Microsoft XPS D...
> 0 3 ATLLAPHROTTENBE
> CutePDF Writer
> 0 3 ATLLAPHROTTENBE
> Building B 5th ... \\atla-prnt01\B...
> 0 3 B5-Canon01 \\atla-prnt01
> Bldg B 5th Floo... \\atla-prnt01\B...
> 0 3 B5-Canon02 \\atla-prnt01
>
> Let's see what happens if I examine the Default property (which you'll
> see in the Get-Member statement above if you run it) of the 3rd
> printer, again remembering arrays start at 0.
>
> 38# $a[2].Default
> True
>
> That's the default printer. How to find the share name?
>
> 44# $prnPath = $a[2].Name
> 45# $prnPath
> \\atla-prnt01\B5-Canon01
>
> Then a "net use lpt2: $prnPath" would finish the mapping.
>
> HTH
>



My System SpecsSystem Spec
Closed Thread
Update your Vista Drivers Update Your Drivers Now!!

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Printing From School Server C J Vista networking & sharing 2 03-22-2008 08:59 PM
Re: printing on server 2003 x64 Bruce Sanderson Vista print fax & scan 0 03-09-2008 10:02 PM
Vista & XP mixed Term Serv printing Marc Medina Vista print fax & scan 0 10-17-2007 11:25 AM
Command doesn't work in PowerShell term but works in DOS term Frank PowerShell 3 06-14-2007 02:19 PM
The term '>' is not recognized as a cmdlet vinod PowerShell 2 03-16-2007 08:14 AM


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