Get Network Printers From A Remote Computer












3















I am using this to attempt to get a list of printers on a remote computer:



Get-WmiObject win32_printer -ComputerName "$oldPcName" 


The problem is I only get local printers, not those printers from the print server connected to the computer. How can I get a list of the network printers?



My goal is to get a list of network printers on a remote computer, remove them, and add different printers from a different print server.



Thanks










share|improve this question



























    3















    I am using this to attempt to get a list of printers on a remote computer:



    Get-WmiObject win32_printer -ComputerName "$oldPcName" 


    The problem is I only get local printers, not those printers from the print server connected to the computer. How can I get a list of the network printers?



    My goal is to get a list of network printers on a remote computer, remove them, and add different printers from a different print server.



    Thanks










    share|improve this question

























      3












      3








      3








      I am using this to attempt to get a list of printers on a remote computer:



      Get-WmiObject win32_printer -ComputerName "$oldPcName" 


      The problem is I only get local printers, not those printers from the print server connected to the computer. How can I get a list of the network printers?



      My goal is to get a list of network printers on a remote computer, remove them, and add different printers from a different print server.



      Thanks










      share|improve this question














      I am using this to attempt to get a list of printers on a remote computer:



      Get-WmiObject win32_printer -ComputerName "$oldPcName" 


      The problem is I only get local printers, not those printers from the print server connected to the computer. How can I get a list of the network printers?



      My goal is to get a list of network printers on a remote computer, remove them, and add different printers from a different print server.



      Thanks







      powershell network-printer






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 11 '15 at 15:08









      Wayne In YakWayne In Yak

      130115




      130115






















          3 Answers
          3






          active

          oldest

          votes


















          0














          #--------------------------
          #Set Execution Of PSScripts
          #--------------------------

          Set-ExecutionPolicy Unrestricted -force

          #------------
          #Turn Off UAC
          #------------

          New-ItemProperty -Path HKLM:SoftwareMicrosoftWindowsCurrentVersionpoliciessystem -Name EnableLUA -PropertyType DWord -Value 0 -Force

          #------------------------------
          #Enter The Name Of The Computer
          #------------------------------

          $comp = "Name of computer"

          #or if you wish to be prompted for the computer name

          $comp = Read-host 'Enter the name of the computer?'

          #---------------------------------------
          #Starts WinRM Service On Remote Computer
          #---------------------------------------

          Import-Module Remote_PSRemoting -force
          Set-WinRMListener -computername $comp
          Restart-WinRM -computername $comp
          Set-WinRMStartUp -computername $comp

          Start-Sleep -Seconds 60

          #----------------------------------------------
          #Establish a PSSession With The Remote Computer
          #----------------------------------------------

          New-PSSession $comp | Enter-PSSession

          #All of the replace commands are used to strip the extra characters and just #give a \serverprinter path return
          #-----------------------
          #Gets A List Of Printers
          #-----------------------

          $printers1 = Get-childitem -Path HKCU:printersconnections | select name
          $printers2 = $printers1 -replace '.*,,'
          $printers3 = $printers2 -replace ',',''
          $printers = $printers3 -replace '}', ''

          ------------------------------------------------------
          #To Replace The Old Print Server Name With The New One
          ------------------------------------------------------

          $newprinters = $printers -replace 'oldserver','\newserver'

          #--------------------
          #Gets Default Printer
          #--------------------

          $default = Get-itemproperty -Path "HKCU:SoftwareMicrosoftWindows NTCurrentVersionWindows" | select device
          $default1 = $default -replace '.*='
          $default2 = $default1 -replace '()'
          $default3 = $default2 -replace ',winspool'
          $defaultprinter = $default3 -replace ',.*'

          ------------------------------------------------------
          #To Replace The Old Print Server Name With The New One
          ------------------------------------------------------

          $newdefaultprinter = $defaultprinter -replace 'oldserver','\newserver'

          #------------------------
          #Deletes The Old Printers
          #------------------------

          Get-WMIObject Win32_Printer | where{$_.Network -eq 'true'} | foreach{$_.delete()}

          #----------------------------------------
          #Exits PSSession With The Remote Computer
          #----------------------------------------

          Exit-PSSession

          #-----------
          #Turn UAC On
          #-----------

          #Value = 0 through 4 depending on the level of UAC

          New-ItemProperty -Path HKLM:SoftwareMicrosoftWindowsCurrentVersionpoliciessystem -Name ConsentPromptBehaviorAdmin -PropertyType DWord -Value 2 -Force

          #------------------------------------
          #Turn Off Execution Policy Of Scripts
          #------------------------------------

          Set-ExecutionPolicy undefined -Force

          #####This is as far as I could get with it. I always turn off UAC and Enable Scripts in the beginning and turn them back on ant the end. The summary of this script will give you the new network Printer paths and the users default printers. It also deletes the users old network printers. With powershell versions before windows 8 and server 2012, you would have to create a logon script to add the new printers and mark the default printer using WMI commands. Use could also use a csv file with a list of computer names as an input if you wish to run this command on multiple computers. It would look something like...


          $csv = Import-csv -Path pathofcsvfile
          foreach ($line in $csv) {

          #With a bracket at the end to run through each computer in the list...


          This is all much easier with newer versions of Windows as they have the Get-printers cmdlet...



          Hopefully that can get you started... I would love to see someone finish this script as I have not had the time at work to do so...






          share|improve this answer


























          • I forgot to mention, you need to download the psremoting module from gallery.technet.microsoft.com/scriptcenter/… and place in the c:windwowssystem32windowsPowerShellv1.0Modules folder on the machine you are running the script from.

            – ninjamonkeysensai
            Apr 5 '15 at 0:00











          • Added the modules to the folder mentioned, get this error: The specified module 'Remote_PSRemoting' was not loaded because no valid module file was found in any module directory.

            – Wayne In Yak
            Jul 30 '15 at 20:35






          • 1





            "Set-ExecutionPolicy Unrestricted" This is extremely bad PowerShell practice - you should use "RemoteSigned" instead

            – InterLinked
            Jan 4 '17 at 17:40



















          0














          On Windows 7



          To see networked printers, I read the registry



          Function InstalledPrinters ($ComputerName)
          {
          Invoke-Command -ComputerName $ComputerName -ScriptBlock {
          $InstalledPrinters = Get-ChildItem "HKLM:SOFTWAREMicrosoftWindows NTCurrentVersionPrintConnections"
          $InstalledPrinters | Add-Member -Name 'PrinterName' -MemberType NoteProperty -Value ""
          Foreach ($InstalledPrinter in $InstalledPrinters) {$InstalledPrinter.PrinterName = $InstalledPrinter.GetValue("Printer").split("")[3]}
          Return $InstalledPrinters | sort PrinterName | select PSComputerName, PrinterName
          }
          }


          To remove a network printer:



          rundll32.exe PRINTUI.DLL PrintUIEntry /gd /c\$ComputerName /n\$PrintServer$PrinterName Gw /q


          To install a network printer:



          rundll32.exe PRINTUI.DLL PrintUIEntry /ga /c\$ComputerName /n\$PrintServer$PrinterName Gw /q





          share|improve this answer


























          • TechNet reference for PrintUIEntry.

            – Ben N
            Jul 1 '16 at 20:59



















          0














          Hmm. There might be a way to do this with a Raspberry Pi. You connect the raspberry pi to the printer and to wifi, you enable port forwarding for ssh or use VNC viewer to access the Raspberry Pi. Using VNC, you can transfer files to the Raspberry Pi over the network. You then get the Raspberry Pi to print out the files you want.



          Its not the best straightforward idea, but thats the only way I know of. Raspberry Pi are also very cheap. Latest model only cost £35. If you wanted to do this way, you would need to make a VNC account, then add your Raspberry Pi into your VNC address book. To do this you need to have Raspbian Desktop, and login to your VNC account on the raspberry Pi.



          Raspberry Pi Specs:
          1GB DDR2 Ram,
          1.4GHZ arm processor,
          GPIO pins






          share|improve this answer
























          • Did not see that this post is 3 years old... sorry if I bumped it.

            – The Royal Noob
            Sep 10 '18 at 19:35











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f876642%2fget-network-printers-from-a-remote-computer%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          3 Answers
          3






          active

          oldest

          votes








          3 Answers
          3






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          #--------------------------
          #Set Execution Of PSScripts
          #--------------------------

          Set-ExecutionPolicy Unrestricted -force

          #------------
          #Turn Off UAC
          #------------

          New-ItemProperty -Path HKLM:SoftwareMicrosoftWindowsCurrentVersionpoliciessystem -Name EnableLUA -PropertyType DWord -Value 0 -Force

          #------------------------------
          #Enter The Name Of The Computer
          #------------------------------

          $comp = "Name of computer"

          #or if you wish to be prompted for the computer name

          $comp = Read-host 'Enter the name of the computer?'

          #---------------------------------------
          #Starts WinRM Service On Remote Computer
          #---------------------------------------

          Import-Module Remote_PSRemoting -force
          Set-WinRMListener -computername $comp
          Restart-WinRM -computername $comp
          Set-WinRMStartUp -computername $comp

          Start-Sleep -Seconds 60

          #----------------------------------------------
          #Establish a PSSession With The Remote Computer
          #----------------------------------------------

          New-PSSession $comp | Enter-PSSession

          #All of the replace commands are used to strip the extra characters and just #give a \serverprinter path return
          #-----------------------
          #Gets A List Of Printers
          #-----------------------

          $printers1 = Get-childitem -Path HKCU:printersconnections | select name
          $printers2 = $printers1 -replace '.*,,'
          $printers3 = $printers2 -replace ',',''
          $printers = $printers3 -replace '}', ''

          ------------------------------------------------------
          #To Replace The Old Print Server Name With The New One
          ------------------------------------------------------

          $newprinters = $printers -replace 'oldserver','\newserver'

          #--------------------
          #Gets Default Printer
          #--------------------

          $default = Get-itemproperty -Path "HKCU:SoftwareMicrosoftWindows NTCurrentVersionWindows" | select device
          $default1 = $default -replace '.*='
          $default2 = $default1 -replace '()'
          $default3 = $default2 -replace ',winspool'
          $defaultprinter = $default3 -replace ',.*'

          ------------------------------------------------------
          #To Replace The Old Print Server Name With The New One
          ------------------------------------------------------

          $newdefaultprinter = $defaultprinter -replace 'oldserver','\newserver'

          #------------------------
          #Deletes The Old Printers
          #------------------------

          Get-WMIObject Win32_Printer | where{$_.Network -eq 'true'} | foreach{$_.delete()}

          #----------------------------------------
          #Exits PSSession With The Remote Computer
          #----------------------------------------

          Exit-PSSession

          #-----------
          #Turn UAC On
          #-----------

          #Value = 0 through 4 depending on the level of UAC

          New-ItemProperty -Path HKLM:SoftwareMicrosoftWindowsCurrentVersionpoliciessystem -Name ConsentPromptBehaviorAdmin -PropertyType DWord -Value 2 -Force

          #------------------------------------
          #Turn Off Execution Policy Of Scripts
          #------------------------------------

          Set-ExecutionPolicy undefined -Force

          #####This is as far as I could get with it. I always turn off UAC and Enable Scripts in the beginning and turn them back on ant the end. The summary of this script will give you the new network Printer paths and the users default printers. It also deletes the users old network printers. With powershell versions before windows 8 and server 2012, you would have to create a logon script to add the new printers and mark the default printer using WMI commands. Use could also use a csv file with a list of computer names as an input if you wish to run this command on multiple computers. It would look something like...


          $csv = Import-csv -Path pathofcsvfile
          foreach ($line in $csv) {

          #With a bracket at the end to run through each computer in the list...


          This is all much easier with newer versions of Windows as they have the Get-printers cmdlet...



          Hopefully that can get you started... I would love to see someone finish this script as I have not had the time at work to do so...






          share|improve this answer


























          • I forgot to mention, you need to download the psremoting module from gallery.technet.microsoft.com/scriptcenter/… and place in the c:windwowssystem32windowsPowerShellv1.0Modules folder on the machine you are running the script from.

            – ninjamonkeysensai
            Apr 5 '15 at 0:00











          • Added the modules to the folder mentioned, get this error: The specified module 'Remote_PSRemoting' was not loaded because no valid module file was found in any module directory.

            – Wayne In Yak
            Jul 30 '15 at 20:35






          • 1





            "Set-ExecutionPolicy Unrestricted" This is extremely bad PowerShell practice - you should use "RemoteSigned" instead

            – InterLinked
            Jan 4 '17 at 17:40
















          0














          #--------------------------
          #Set Execution Of PSScripts
          #--------------------------

          Set-ExecutionPolicy Unrestricted -force

          #------------
          #Turn Off UAC
          #------------

          New-ItemProperty -Path HKLM:SoftwareMicrosoftWindowsCurrentVersionpoliciessystem -Name EnableLUA -PropertyType DWord -Value 0 -Force

          #------------------------------
          #Enter The Name Of The Computer
          #------------------------------

          $comp = "Name of computer"

          #or if you wish to be prompted for the computer name

          $comp = Read-host 'Enter the name of the computer?'

          #---------------------------------------
          #Starts WinRM Service On Remote Computer
          #---------------------------------------

          Import-Module Remote_PSRemoting -force
          Set-WinRMListener -computername $comp
          Restart-WinRM -computername $comp
          Set-WinRMStartUp -computername $comp

          Start-Sleep -Seconds 60

          #----------------------------------------------
          #Establish a PSSession With The Remote Computer
          #----------------------------------------------

          New-PSSession $comp | Enter-PSSession

          #All of the replace commands are used to strip the extra characters and just #give a \serverprinter path return
          #-----------------------
          #Gets A List Of Printers
          #-----------------------

          $printers1 = Get-childitem -Path HKCU:printersconnections | select name
          $printers2 = $printers1 -replace '.*,,'
          $printers3 = $printers2 -replace ',',''
          $printers = $printers3 -replace '}', ''

          ------------------------------------------------------
          #To Replace The Old Print Server Name With The New One
          ------------------------------------------------------

          $newprinters = $printers -replace 'oldserver','\newserver'

          #--------------------
          #Gets Default Printer
          #--------------------

          $default = Get-itemproperty -Path "HKCU:SoftwareMicrosoftWindows NTCurrentVersionWindows" | select device
          $default1 = $default -replace '.*='
          $default2 = $default1 -replace '()'
          $default3 = $default2 -replace ',winspool'
          $defaultprinter = $default3 -replace ',.*'

          ------------------------------------------------------
          #To Replace The Old Print Server Name With The New One
          ------------------------------------------------------

          $newdefaultprinter = $defaultprinter -replace 'oldserver','\newserver'

          #------------------------
          #Deletes The Old Printers
          #------------------------

          Get-WMIObject Win32_Printer | where{$_.Network -eq 'true'} | foreach{$_.delete()}

          #----------------------------------------
          #Exits PSSession With The Remote Computer
          #----------------------------------------

          Exit-PSSession

          #-----------
          #Turn UAC On
          #-----------

          #Value = 0 through 4 depending on the level of UAC

          New-ItemProperty -Path HKLM:SoftwareMicrosoftWindowsCurrentVersionpoliciessystem -Name ConsentPromptBehaviorAdmin -PropertyType DWord -Value 2 -Force

          #------------------------------------
          #Turn Off Execution Policy Of Scripts
          #------------------------------------

          Set-ExecutionPolicy undefined -Force

          #####This is as far as I could get with it. I always turn off UAC and Enable Scripts in the beginning and turn them back on ant the end. The summary of this script will give you the new network Printer paths and the users default printers. It also deletes the users old network printers. With powershell versions before windows 8 and server 2012, you would have to create a logon script to add the new printers and mark the default printer using WMI commands. Use could also use a csv file with a list of computer names as an input if you wish to run this command on multiple computers. It would look something like...


          $csv = Import-csv -Path pathofcsvfile
          foreach ($line in $csv) {

          #With a bracket at the end to run through each computer in the list...


          This is all much easier with newer versions of Windows as they have the Get-printers cmdlet...



          Hopefully that can get you started... I would love to see someone finish this script as I have not had the time at work to do so...






          share|improve this answer


























          • I forgot to mention, you need to download the psremoting module from gallery.technet.microsoft.com/scriptcenter/… and place in the c:windwowssystem32windowsPowerShellv1.0Modules folder on the machine you are running the script from.

            – ninjamonkeysensai
            Apr 5 '15 at 0:00











          • Added the modules to the folder mentioned, get this error: The specified module 'Remote_PSRemoting' was not loaded because no valid module file was found in any module directory.

            – Wayne In Yak
            Jul 30 '15 at 20:35






          • 1





            "Set-ExecutionPolicy Unrestricted" This is extremely bad PowerShell practice - you should use "RemoteSigned" instead

            – InterLinked
            Jan 4 '17 at 17:40














          0












          0








          0







          #--------------------------
          #Set Execution Of PSScripts
          #--------------------------

          Set-ExecutionPolicy Unrestricted -force

          #------------
          #Turn Off UAC
          #------------

          New-ItemProperty -Path HKLM:SoftwareMicrosoftWindowsCurrentVersionpoliciessystem -Name EnableLUA -PropertyType DWord -Value 0 -Force

          #------------------------------
          #Enter The Name Of The Computer
          #------------------------------

          $comp = "Name of computer"

          #or if you wish to be prompted for the computer name

          $comp = Read-host 'Enter the name of the computer?'

          #---------------------------------------
          #Starts WinRM Service On Remote Computer
          #---------------------------------------

          Import-Module Remote_PSRemoting -force
          Set-WinRMListener -computername $comp
          Restart-WinRM -computername $comp
          Set-WinRMStartUp -computername $comp

          Start-Sleep -Seconds 60

          #----------------------------------------------
          #Establish a PSSession With The Remote Computer
          #----------------------------------------------

          New-PSSession $comp | Enter-PSSession

          #All of the replace commands are used to strip the extra characters and just #give a \serverprinter path return
          #-----------------------
          #Gets A List Of Printers
          #-----------------------

          $printers1 = Get-childitem -Path HKCU:printersconnections | select name
          $printers2 = $printers1 -replace '.*,,'
          $printers3 = $printers2 -replace ',',''
          $printers = $printers3 -replace '}', ''

          ------------------------------------------------------
          #To Replace The Old Print Server Name With The New One
          ------------------------------------------------------

          $newprinters = $printers -replace 'oldserver','\newserver'

          #--------------------
          #Gets Default Printer
          #--------------------

          $default = Get-itemproperty -Path "HKCU:SoftwareMicrosoftWindows NTCurrentVersionWindows" | select device
          $default1 = $default -replace '.*='
          $default2 = $default1 -replace '()'
          $default3 = $default2 -replace ',winspool'
          $defaultprinter = $default3 -replace ',.*'

          ------------------------------------------------------
          #To Replace The Old Print Server Name With The New One
          ------------------------------------------------------

          $newdefaultprinter = $defaultprinter -replace 'oldserver','\newserver'

          #------------------------
          #Deletes The Old Printers
          #------------------------

          Get-WMIObject Win32_Printer | where{$_.Network -eq 'true'} | foreach{$_.delete()}

          #----------------------------------------
          #Exits PSSession With The Remote Computer
          #----------------------------------------

          Exit-PSSession

          #-----------
          #Turn UAC On
          #-----------

          #Value = 0 through 4 depending on the level of UAC

          New-ItemProperty -Path HKLM:SoftwareMicrosoftWindowsCurrentVersionpoliciessystem -Name ConsentPromptBehaviorAdmin -PropertyType DWord -Value 2 -Force

          #------------------------------------
          #Turn Off Execution Policy Of Scripts
          #------------------------------------

          Set-ExecutionPolicy undefined -Force

          #####This is as far as I could get with it. I always turn off UAC and Enable Scripts in the beginning and turn them back on ant the end. The summary of this script will give you the new network Printer paths and the users default printers. It also deletes the users old network printers. With powershell versions before windows 8 and server 2012, you would have to create a logon script to add the new printers and mark the default printer using WMI commands. Use could also use a csv file with a list of computer names as an input if you wish to run this command on multiple computers. It would look something like...


          $csv = Import-csv -Path pathofcsvfile
          foreach ($line in $csv) {

          #With a bracket at the end to run through each computer in the list...


          This is all much easier with newer versions of Windows as they have the Get-printers cmdlet...



          Hopefully that can get you started... I would love to see someone finish this script as I have not had the time at work to do so...






          share|improve this answer















          #--------------------------
          #Set Execution Of PSScripts
          #--------------------------

          Set-ExecutionPolicy Unrestricted -force

          #------------
          #Turn Off UAC
          #------------

          New-ItemProperty -Path HKLM:SoftwareMicrosoftWindowsCurrentVersionpoliciessystem -Name EnableLUA -PropertyType DWord -Value 0 -Force

          #------------------------------
          #Enter The Name Of The Computer
          #------------------------------

          $comp = "Name of computer"

          #or if you wish to be prompted for the computer name

          $comp = Read-host 'Enter the name of the computer?'

          #---------------------------------------
          #Starts WinRM Service On Remote Computer
          #---------------------------------------

          Import-Module Remote_PSRemoting -force
          Set-WinRMListener -computername $comp
          Restart-WinRM -computername $comp
          Set-WinRMStartUp -computername $comp

          Start-Sleep -Seconds 60

          #----------------------------------------------
          #Establish a PSSession With The Remote Computer
          #----------------------------------------------

          New-PSSession $comp | Enter-PSSession

          #All of the replace commands are used to strip the extra characters and just #give a \serverprinter path return
          #-----------------------
          #Gets A List Of Printers
          #-----------------------

          $printers1 = Get-childitem -Path HKCU:printersconnections | select name
          $printers2 = $printers1 -replace '.*,,'
          $printers3 = $printers2 -replace ',',''
          $printers = $printers3 -replace '}', ''

          ------------------------------------------------------
          #To Replace The Old Print Server Name With The New One
          ------------------------------------------------------

          $newprinters = $printers -replace 'oldserver','\newserver'

          #--------------------
          #Gets Default Printer
          #--------------------

          $default = Get-itemproperty -Path "HKCU:SoftwareMicrosoftWindows NTCurrentVersionWindows" | select device
          $default1 = $default -replace '.*='
          $default2 = $default1 -replace '()'
          $default3 = $default2 -replace ',winspool'
          $defaultprinter = $default3 -replace ',.*'

          ------------------------------------------------------
          #To Replace The Old Print Server Name With The New One
          ------------------------------------------------------

          $newdefaultprinter = $defaultprinter -replace 'oldserver','\newserver'

          #------------------------
          #Deletes The Old Printers
          #------------------------

          Get-WMIObject Win32_Printer | where{$_.Network -eq 'true'} | foreach{$_.delete()}

          #----------------------------------------
          #Exits PSSession With The Remote Computer
          #----------------------------------------

          Exit-PSSession

          #-----------
          #Turn UAC On
          #-----------

          #Value = 0 through 4 depending on the level of UAC

          New-ItemProperty -Path HKLM:SoftwareMicrosoftWindowsCurrentVersionpoliciessystem -Name ConsentPromptBehaviorAdmin -PropertyType DWord -Value 2 -Force

          #------------------------------------
          #Turn Off Execution Policy Of Scripts
          #------------------------------------

          Set-ExecutionPolicy undefined -Force

          #####This is as far as I could get with it. I always turn off UAC and Enable Scripts in the beginning and turn them back on ant the end. The summary of this script will give you the new network Printer paths and the users default printers. It also deletes the users old network printers. With powershell versions before windows 8 and server 2012, you would have to create a logon script to add the new printers and mark the default printer using WMI commands. Use could also use a csv file with a list of computer names as an input if you wish to run this command on multiple computers. It would look something like...


          $csv = Import-csv -Path pathofcsvfile
          foreach ($line in $csv) {

          #With a bracket at the end to run through each computer in the list...


          This is all much easier with newer versions of Windows as they have the Get-printers cmdlet...



          Hopefully that can get you started... I would love to see someone finish this script as I have not had the time at work to do so...







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Apr 5 '15 at 0:47









          BenjiWiebe

          6,61493458




          6,61493458










          answered Apr 4 '15 at 21:55









          ninjamonkeysensaininjamonkeysensai

          1




          1













          • I forgot to mention, you need to download the psremoting module from gallery.technet.microsoft.com/scriptcenter/… and place in the c:windwowssystem32windowsPowerShellv1.0Modules folder on the machine you are running the script from.

            – ninjamonkeysensai
            Apr 5 '15 at 0:00











          • Added the modules to the folder mentioned, get this error: The specified module 'Remote_PSRemoting' was not loaded because no valid module file was found in any module directory.

            – Wayne In Yak
            Jul 30 '15 at 20:35






          • 1





            "Set-ExecutionPolicy Unrestricted" This is extremely bad PowerShell practice - you should use "RemoteSigned" instead

            – InterLinked
            Jan 4 '17 at 17:40



















          • I forgot to mention, you need to download the psremoting module from gallery.technet.microsoft.com/scriptcenter/… and place in the c:windwowssystem32windowsPowerShellv1.0Modules folder on the machine you are running the script from.

            – ninjamonkeysensai
            Apr 5 '15 at 0:00











          • Added the modules to the folder mentioned, get this error: The specified module 'Remote_PSRemoting' was not loaded because no valid module file was found in any module directory.

            – Wayne In Yak
            Jul 30 '15 at 20:35






          • 1





            "Set-ExecutionPolicy Unrestricted" This is extremely bad PowerShell practice - you should use "RemoteSigned" instead

            – InterLinked
            Jan 4 '17 at 17:40

















          I forgot to mention, you need to download the psremoting module from gallery.technet.microsoft.com/scriptcenter/… and place in the c:windwowssystem32windowsPowerShellv1.0Modules folder on the machine you are running the script from.

          – ninjamonkeysensai
          Apr 5 '15 at 0:00





          I forgot to mention, you need to download the psremoting module from gallery.technet.microsoft.com/scriptcenter/… and place in the c:windwowssystem32windowsPowerShellv1.0Modules folder on the machine you are running the script from.

          – ninjamonkeysensai
          Apr 5 '15 at 0:00













          Added the modules to the folder mentioned, get this error: The specified module 'Remote_PSRemoting' was not loaded because no valid module file was found in any module directory.

          – Wayne In Yak
          Jul 30 '15 at 20:35





          Added the modules to the folder mentioned, get this error: The specified module 'Remote_PSRemoting' was not loaded because no valid module file was found in any module directory.

          – Wayne In Yak
          Jul 30 '15 at 20:35




          1




          1





          "Set-ExecutionPolicy Unrestricted" This is extremely bad PowerShell practice - you should use "RemoteSigned" instead

          – InterLinked
          Jan 4 '17 at 17:40





          "Set-ExecutionPolicy Unrestricted" This is extremely bad PowerShell practice - you should use "RemoteSigned" instead

          – InterLinked
          Jan 4 '17 at 17:40













          0














          On Windows 7



          To see networked printers, I read the registry



          Function InstalledPrinters ($ComputerName)
          {
          Invoke-Command -ComputerName $ComputerName -ScriptBlock {
          $InstalledPrinters = Get-ChildItem "HKLM:SOFTWAREMicrosoftWindows NTCurrentVersionPrintConnections"
          $InstalledPrinters | Add-Member -Name 'PrinterName' -MemberType NoteProperty -Value ""
          Foreach ($InstalledPrinter in $InstalledPrinters) {$InstalledPrinter.PrinterName = $InstalledPrinter.GetValue("Printer").split("")[3]}
          Return $InstalledPrinters | sort PrinterName | select PSComputerName, PrinterName
          }
          }


          To remove a network printer:



          rundll32.exe PRINTUI.DLL PrintUIEntry /gd /c\$ComputerName /n\$PrintServer$PrinterName Gw /q


          To install a network printer:



          rundll32.exe PRINTUI.DLL PrintUIEntry /ga /c\$ComputerName /n\$PrintServer$PrinterName Gw /q





          share|improve this answer


























          • TechNet reference for PrintUIEntry.

            – Ben N
            Jul 1 '16 at 20:59
















          0














          On Windows 7



          To see networked printers, I read the registry



          Function InstalledPrinters ($ComputerName)
          {
          Invoke-Command -ComputerName $ComputerName -ScriptBlock {
          $InstalledPrinters = Get-ChildItem "HKLM:SOFTWAREMicrosoftWindows NTCurrentVersionPrintConnections"
          $InstalledPrinters | Add-Member -Name 'PrinterName' -MemberType NoteProperty -Value ""
          Foreach ($InstalledPrinter in $InstalledPrinters) {$InstalledPrinter.PrinterName = $InstalledPrinter.GetValue("Printer").split("")[3]}
          Return $InstalledPrinters | sort PrinterName | select PSComputerName, PrinterName
          }
          }


          To remove a network printer:



          rundll32.exe PRINTUI.DLL PrintUIEntry /gd /c\$ComputerName /n\$PrintServer$PrinterName Gw /q


          To install a network printer:



          rundll32.exe PRINTUI.DLL PrintUIEntry /ga /c\$ComputerName /n\$PrintServer$PrinterName Gw /q





          share|improve this answer


























          • TechNet reference for PrintUIEntry.

            – Ben N
            Jul 1 '16 at 20:59














          0












          0








          0







          On Windows 7



          To see networked printers, I read the registry



          Function InstalledPrinters ($ComputerName)
          {
          Invoke-Command -ComputerName $ComputerName -ScriptBlock {
          $InstalledPrinters = Get-ChildItem "HKLM:SOFTWAREMicrosoftWindows NTCurrentVersionPrintConnections"
          $InstalledPrinters | Add-Member -Name 'PrinterName' -MemberType NoteProperty -Value ""
          Foreach ($InstalledPrinter in $InstalledPrinters) {$InstalledPrinter.PrinterName = $InstalledPrinter.GetValue("Printer").split("")[3]}
          Return $InstalledPrinters | sort PrinterName | select PSComputerName, PrinterName
          }
          }


          To remove a network printer:



          rundll32.exe PRINTUI.DLL PrintUIEntry /gd /c\$ComputerName /n\$PrintServer$PrinterName Gw /q


          To install a network printer:



          rundll32.exe PRINTUI.DLL PrintUIEntry /ga /c\$ComputerName /n\$PrintServer$PrinterName Gw /q





          share|improve this answer















          On Windows 7



          To see networked printers, I read the registry



          Function InstalledPrinters ($ComputerName)
          {
          Invoke-Command -ComputerName $ComputerName -ScriptBlock {
          $InstalledPrinters = Get-ChildItem "HKLM:SOFTWAREMicrosoftWindows NTCurrentVersionPrintConnections"
          $InstalledPrinters | Add-Member -Name 'PrinterName' -MemberType NoteProperty -Value ""
          Foreach ($InstalledPrinter in $InstalledPrinters) {$InstalledPrinter.PrinterName = $InstalledPrinter.GetValue("Printer").split("")[3]}
          Return $InstalledPrinters | sort PrinterName | select PSComputerName, PrinterName
          }
          }


          To remove a network printer:



          rundll32.exe PRINTUI.DLL PrintUIEntry /gd /c\$ComputerName /n\$PrintServer$PrinterName Gw /q


          To install a network printer:



          rundll32.exe PRINTUI.DLL PrintUIEntry /ga /c\$ComputerName /n\$PrintServer$PrinterName Gw /q






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jul 1 '16 at 20:39









          DavidPostill

          104k25225259




          104k25225259










          answered Jul 1 '16 at 20:32









          Wayne GaultWayne Gault

          1




          1













          • TechNet reference for PrintUIEntry.

            – Ben N
            Jul 1 '16 at 20:59



















          • TechNet reference for PrintUIEntry.

            – Ben N
            Jul 1 '16 at 20:59

















          TechNet reference for PrintUIEntry.

          – Ben N
          Jul 1 '16 at 20:59





          TechNet reference for PrintUIEntry.

          – Ben N
          Jul 1 '16 at 20:59











          0














          Hmm. There might be a way to do this with a Raspberry Pi. You connect the raspberry pi to the printer and to wifi, you enable port forwarding for ssh or use VNC viewer to access the Raspberry Pi. Using VNC, you can transfer files to the Raspberry Pi over the network. You then get the Raspberry Pi to print out the files you want.



          Its not the best straightforward idea, but thats the only way I know of. Raspberry Pi are also very cheap. Latest model only cost £35. If you wanted to do this way, you would need to make a VNC account, then add your Raspberry Pi into your VNC address book. To do this you need to have Raspbian Desktop, and login to your VNC account on the raspberry Pi.



          Raspberry Pi Specs:
          1GB DDR2 Ram,
          1.4GHZ arm processor,
          GPIO pins






          share|improve this answer
























          • Did not see that this post is 3 years old... sorry if I bumped it.

            – The Royal Noob
            Sep 10 '18 at 19:35
















          0














          Hmm. There might be a way to do this with a Raspberry Pi. You connect the raspberry pi to the printer and to wifi, you enable port forwarding for ssh or use VNC viewer to access the Raspberry Pi. Using VNC, you can transfer files to the Raspberry Pi over the network. You then get the Raspberry Pi to print out the files you want.



          Its not the best straightforward idea, but thats the only way I know of. Raspberry Pi are also very cheap. Latest model only cost £35. If you wanted to do this way, you would need to make a VNC account, then add your Raspberry Pi into your VNC address book. To do this you need to have Raspbian Desktop, and login to your VNC account on the raspberry Pi.



          Raspberry Pi Specs:
          1GB DDR2 Ram,
          1.4GHZ arm processor,
          GPIO pins






          share|improve this answer
























          • Did not see that this post is 3 years old... sorry if I bumped it.

            – The Royal Noob
            Sep 10 '18 at 19:35














          0












          0








          0







          Hmm. There might be a way to do this with a Raspberry Pi. You connect the raspberry pi to the printer and to wifi, you enable port forwarding for ssh or use VNC viewer to access the Raspberry Pi. Using VNC, you can transfer files to the Raspberry Pi over the network. You then get the Raspberry Pi to print out the files you want.



          Its not the best straightforward idea, but thats the only way I know of. Raspberry Pi are also very cheap. Latest model only cost £35. If you wanted to do this way, you would need to make a VNC account, then add your Raspberry Pi into your VNC address book. To do this you need to have Raspbian Desktop, and login to your VNC account on the raspberry Pi.



          Raspberry Pi Specs:
          1GB DDR2 Ram,
          1.4GHZ arm processor,
          GPIO pins






          share|improve this answer













          Hmm. There might be a way to do this with a Raspberry Pi. You connect the raspberry pi to the printer and to wifi, you enable port forwarding for ssh or use VNC viewer to access the Raspberry Pi. Using VNC, you can transfer files to the Raspberry Pi over the network. You then get the Raspberry Pi to print out the files you want.



          Its not the best straightforward idea, but thats the only way I know of. Raspberry Pi are also very cheap. Latest model only cost £35. If you wanted to do this way, you would need to make a VNC account, then add your Raspberry Pi into your VNC address book. To do this you need to have Raspbian Desktop, and login to your VNC account on the raspberry Pi.



          Raspberry Pi Specs:
          1GB DDR2 Ram,
          1.4GHZ arm processor,
          GPIO pins







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Sep 10 '18 at 19:34









          The Royal NoobThe Royal Noob

          31




          31













          • Did not see that this post is 3 years old... sorry if I bumped it.

            – The Royal Noob
            Sep 10 '18 at 19:35



















          • Did not see that this post is 3 years old... sorry if I bumped it.

            – The Royal Noob
            Sep 10 '18 at 19:35

















          Did not see that this post is 3 years old... sorry if I bumped it.

          – The Royal Noob
          Sep 10 '18 at 19:35





          Did not see that this post is 3 years old... sorry if I bumped it.

          – The Royal Noob
          Sep 10 '18 at 19:35


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f876642%2fget-network-printers-from-a-remote-computer%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          If I really need a card on my start hand, how many mulligans make sense? [duplicate]

          Alcedinidae

          Can an atomic nucleus contain both particles and antiparticles? [duplicate]