How can I filter a query to printers that are on a specific print server?

When I run the following script I get no hits.
________________
strComputer = "."
Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPrinters = objWMIService.ExecQuery ("Select * from
Win32_Printer Where ServerName='\\print_server'")

For Each objItem in colInstalledPrinters
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "ServerName: " & objItem.ServerName
Wscript.Echo "Shared: " & objItem.Shared
Wscript.Echo "ShareName: " & objItem.ShareName
Wscript.Echo "Status: " & objItem.Status
Next
________________

The script was built with script-o-matic except I added -- Where
ServerName='\\print_server'") -- which I am pretty sure is the correct
syntax. Of course I substituted my real printer servers name for
\\print_server .

Any suggestions would be appreciated.

Ian Matthews
MCSE2001

Re: Simple Script Returns No Entries by Torgeir

Torgeir
Tue Apr 05 12:47:01 CDT 2005


Multipost; response in microsoft.public.windows.server.scripting


What is the accepted way to share a message across multiple newsgroups?
http://smjg.port5.com/faqs/usenet/xpost.html

and

Multiposting vs Crossposting
http://www.blakjak.demon.co.uk/mul_crss.htm

and

Please don't multi-post.
http://www.aspfaq.com/etiquette.asp?id=5003


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Re: Simple Script Returns No Entries by Ian

Ian
Tue Apr 05 13:17:09 CDT 2005

corrected syntax to ...Where ServerName='\\\\print_server'") and that
resolved the matter, although I do not understand when/why I need to double
up the slashes.

"Ian Matthews" <imatthews@arcis.com> wrote in message
news:eRqTXQgOFHA.4028@tk2msftngp13.phx.gbl...
> How can I filter a query to printers that are on a specific print server?
>
> When I run the following script I get no hits.
> ________________
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:" &
> "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
>
> Set colInstalledPrinters = objWMIService.ExecQuery ("Select * from
> Win32_Printer Where ServerName='\\print_server'")
>
> For Each objItem in colInstalledPrinters
> Wscript.Echo "Name: " & objItem.Name
> Wscript.Echo "ServerName: " & objItem.ServerName
> Wscript.Echo "Shared: " & objItem.Shared
> Wscript.Echo "ShareName: " & objItem.ShareName
> Wscript.Echo "Status: " & objItem.Status
> Next
> ________________
>
> The script was built with script-o-matic except I added -- Where
> ServerName='\\print_server'") -- which I am pretty sure is the correct
> syntax. Of course I substituted my real printer servers name for
> \\print_server .
>
> Any suggestions would be appreciated.
>
> Ian Matthews
> MCSE2001
>



Re: Simple Script Returns No Entries by Ian

Ian
Tue Apr 05 17:47:36 CDT 2005

Hi Torgeir;

Right you are! I thought I was in the other newsgroup when I posted this
one. Accidental multipost.


"Torgeir Bakken (MVP)" <Torgeir.Bakken-spam@hydro.com> wrote in message
news:eF5n3egOFHA.1040@TK2MSFTNGP12.phx.gbl...
>
> Multipost; response in microsoft.public.windows.server.scripting
>
>
> What is the accepted way to share a message across multiple newsgroups?
> http://smjg.port5.com/faqs/usenet/xpost.html
>
> and
>
> Multiposting vs Crossposting
> http://www.blakjak.demon.co.uk/mul_crss.htm
>
> and
>
> Please don't multi-post.
> http://www.aspfaq.com/etiquette.asp?id=5003
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx