Forum Discussion

mpd53210's avatar
mpd53210
Copper Contributor
Jun 09, 2020

how to change printer port address on windows 7

Hi,

I hope you and your family are safe. 

B.L.M.

 

I am running ps script to change remote pc printer driver port address. this works fine for windows 10. However if the target pc is windows 7 i get "portname" property doesn't exist . 

 

The property 'PortName' cannot be found on this object. Verify that the property exists and can be set.

 

 

any ideas?

 

  • mpd53210's avatar
    mpd53210
    Copper Contributor
    during debugging I saw that cimproperty has the portname property. however I do not know how to read or update it.
  • mpd53210's avatar
    mpd53210
    Copper Contributor

    Hello again. I have the following script. Every time I run it shows me an error.
    $a=Get-Printer -ComputerName $pcname1 | Where-Object {$_.
    PortName -like $OldIP} 
    $a.PortName = $NewIP
    Set-Printer -InputObject $a

    I get this error
    The property 'PortName' cannot be found on this object. Verify that the property exists and can be set
    the error is on line for ($a.PortName = $NewIP)

    during debug, when I hover on $a I can see properties of $a and it has two printers showing. when I drill down into it, I can see portname has the IP address that I need to change.

    • gastone's avatar
      gastone
      Brass Contributor

      mpd53210 

      What  powershell version are you using?

       

      get-host

       

      Probably portname is not supported in your version

      try

       

       $a|gm

       

       to see method an properties of yout object

       

      Report the output here

Resources