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

Creating new Printer-Port and installing new Printer

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 10-11-2006   #1 (permalink)
Jens Schulze
Guest


 

Creating new Printer-Port and installing new Printer

Hello
i found following WSH-Skript at die MSDN-Website. But how can i do this with
the powershell? I do not know how to create a new instance of the
Win32_TCPIPPrinterPort-Class.

thanks Jens

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewPort = objWMIService.Get _
("Win32_TCPIPPrinterPort").SpawnInstance_

objNewPort.Name = "IP_169.254.110.14"
objNewPort.Protocol = 1
objNewPort.HostAddress = "169.254.110.14"
objNewPort.PortNumber = "9999"
objNewPort.SNMPEnabled = False
objNewPort.Put_




My System SpecsSystem Spec
Old 10-11-2006   #2 (permalink)
/\/\o\/\/ [MVP]
Guest


 

RE: Creating new Printer-Port and installing new Printer

this is RC1 code as I have no RC2 handy (for more info about the changes see
my blog series
http://mow001.blogspot.com/2006/10/p...t-in-rc2.html:


# RC2 $p = [WmiClass]'Win32_TCPIPPrinterPort'
$p = new-object management.managementclass Win32_TCPIPPrinterPort

$NewPort = $p.CreateInstance()
$NewPort.Item('Name') = "IP_169.254.110.14"
#...

$NewPort.Put()


Greetings /\/\o\/\/


"Jens Schulze" wrote:

> Hello
> i found following WSH-Skript at die MSDN-Website. But how can i do this with
> the powershell? I do not know how to create a new instance of the
> Win32_TCPIPPrinterPort-Class.
>
> thanks Jens
>
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
> Set objNewPort = objWMIService.Get _
> ("Win32_TCPIPPrinterPort").SpawnInstance_
>
> objNewPort.Name = "IP_169.254.110.14"
> objNewPort.Protocol = 1
> objNewPort.HostAddress = "169.254.110.14"
> objNewPort.PortNumber = "9999"
> objNewPort.SNMPEnabled = False
> objNewPort.Put_
>
>
>
>

My System SpecsSystem Spec
Old 10-11-2006   #3 (permalink)
Jens Schulze
Guest


 

Re: Creating new Printer-Port and installing new Printer

Thank you,

i will test it :-)


"/\/\o\/\/ [MVP]" <oMVP@discussions.microsoft.com> schrieb im Newsbeitrag
news:400366BF-8408-4D30-A5CD-99D71724DA15@microsoft.com...
> this is RC1 code as I have no RC2 handy (for more info about the changes
> see
> my blog series
> http://mow001.blogspot.com/2006/10/p...t-in-rc2.html:
>
>
> # RC2 $p = [WmiClass]'Win32_TCPIPPrinterPort'
> $p = new-object management.managementclass Win32_TCPIPPrinterPort
>
> $NewPort = $p.CreateInstance()
> $NewPort.Item('Name') = "IP_169.254.110.14"
> #...
>
> $NewPort.Put()
>
>
> Greetings /\/\o\/\/
>
>
> "Jens Schulze" wrote:
>
>> Hello
>> i found following WSH-Skript at die MSDN-Website. But how can i do this
>> with
>> the powershell? I do not know how to create a new instance of the
>> Win32_TCPIPPrinterPort-Class.
>>
>> thanks Jens
>>
>> strComputer = "."
>> Set objWMIService = GetObject("winmgmts:" _
>> & "{impersonationLevel=impersonate}!\\" & strComputer &
>> "\root\cimv2")
>> Set objNewPort = objWMIService.Get _
>> ("Win32_TCPIPPrinterPort").SpawnInstance_
>>
>> objNewPort.Name = "IP_169.254.110.14"
>> objNewPort.Protocol = 1
>> objNewPort.HostAddress = "169.254.110.14"
>> objNewPort.PortNumber = "9999"
>> objNewPort.SNMPEnabled = False
>> objNewPort.Put_
>>
>>
>>
>>



My System SpecsSystem Spec
Old 10-11-2006   #4 (permalink)
Jens Schulze
Guest


 

Re: Creating new Printer-Port and installing new Printer

Thank you, works fine :-)


"Jens Schulze" <webmaster@irgendwas.de> schrieb im Newsbeitrag
news:%23asrfrT7GHA.4348@TK2MSFTNGP03.phx.gbl...
> Thank you,
>
> i will test it :-)
>
>
> "/\/\o\/\/ [MVP]" <oMVP@discussions.microsoft.com> schrieb im Newsbeitrag
> news:400366BF-8408-4D30-A5CD-99D71724DA15@microsoft.com...
>> this is RC1 code as I have no RC2 handy (for more info about the changes
>> see
>> my blog series
>> http://mow001.blogspot.com/2006/10/p...t-in-rc2.html:
>>
>>
>> # RC2 $p = [WmiClass]'Win32_TCPIPPrinterPort'
>> $p = new-object management.managementclass Win32_TCPIPPrinterPort
>>
>> $NewPort = $p.CreateInstance()
>> $NewPort.Item('Name') = "IP_169.254.110.14"
>> #...
>>
>> $NewPort.Put()
>>
>>
>> Greetings /\/\o\/\/
>>
>>
>> "Jens Schulze" wrote:
>>
>>> Hello
>>> i found following WSH-Skript at die MSDN-Website. But how can i do this
>>> with
>>> the powershell? I do not know how to create a new instance of the
>>> Win32_TCPIPPrinterPort-Class.
>>>
>>> thanks Jens
>>>
>>> strComputer = "."
>>> Set objWMIService = GetObject("winmgmts:" _
>>> & "{impersonationLevel=impersonate}!\\" & strComputer &
>>> "\root\cimv2")
>>> Set objNewPort = objWMIService.Get _
>>> ("Win32_TCPIPPrinterPort").SpawnInstance_
>>>
>>> objNewPort.Name = "IP_169.254.110.14"
>>> objNewPort.Protocol = 1
>>> objNewPort.HostAddress = "169.254.110.14"
>>> objNewPort.PortNumber = "9999"
>>> objNewPort.SNMPEnabled = False
>>> objNewPort.Put_
>>>
>>>
>>>
>>>

>
>



My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with printer port Nicola Righetti Vista print fax & scan 0 05-21-2008 11:48 AM
printer port tennisann Vista print fax & scan 1 02-12-2008 12:06 PM
Local Printer Port Diane Vista General 2 06-27-2007 07:56 AM
Cannot add printer if creating local port Anuj Vista print fax & scan 2 04-18-2007 11:46 PM


Update your Vista Drivers Update Your Drivers Now!!

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