We help IT Professionals succeed at work.

is there a tool to find out in how many computers on a network a network printer is installed?

High Priority
108 Views
Last Modified: 2020-01-23
hello Team

we have two print servers, we would like to remove one but transfer an important printer to the print that will continue running, the issue is that there are many computers on the network printing to the device on the print server that need to be removed. we would like to know the computers that would be affected so we can go back and reinstall the printer pointing to the new print server.


Thank you in advance.
Comment
Watch Question

AlexA lack of information provides a lack of a decent solution.
CERTIFIED EXPERT

Commented:
Morning,

So, this seems like a simple task that you're complicating quite well. I'm assuming you're on a domain so you can use Group policy preferences to map the new printer on the new server anyway, how many printers are we talking about here?

Also, you can use a login script to pull the printers on the machine.

Regards
Alex

Author

Commented:
Good Morning Alex

Thank you for the quick response.

You are correct I'm in a domain, Windows server 2016. There is an important detail missing in my question, the printer was recently change, I didn't installed the driver for it yet on the print server, the old printer was an HP laserjet and was replace for another hp LJ, but different model, for some reason computers are able to print to new printer even so the driver is different so i guess they are printing to a Q.
 
You mention a GPO will help on it. the amount of computers printing to the device are about 250, but i would like to know what those 250 are so I can at least know which one would be affected.
I guess a login script using Get-printer will be one way to go.
I really appreciate your fast response, this is my first time posting a question, I don't know how to respond about the solution but it's helpful, i will work on it and post results back.

Thank you Alex
A lack of information provides a lack of a decent solution.
CERTIFIED EXPERT
Commented:
It's ok,

So you need to find the printers attached to machines right?

get-printer | export-csv \\domain\sharedlocation\$ENV:Computername.csv

That would export all printers to a CSV file, you can then use excel to collate the data  and then map the printers to each machine.

I didn't installed the driver for it yet on the print server, the old printer was an HP laserjet and was replace for another hp LJ,

Likelihood is it's using a universal printer driver, as such doesn't require further drivers
Fred MarshallPrincipal
CERTIFIED EXPERT

Commented:
While it may seem tidy to remove the printer, what is the downside of adding the new one anyway?
Is there an urgency for removal that tops the urgency for providing the new one?
Now, I do understand that removal is at the core of this question.
I sense that there's something that ties the new printer to the old one.  Same IP address?

Author

Commented:
Good Morning Fred

Yes same IP address, we are demoting the old print server, I already have the printer migrated to the new print server but if i turn the old print server off, no one can print to it unless the old print server is on.

Regards

Hector
Fred MarshallPrincipal
CERTIFIED EXPERT

Commented:
So the workstations are still pointing to the old print server?

Author

Commented:
yes they are.
AlexA lack of information provides a lack of a decent solution.
CERTIFIED EXPERT

Commented:
' put in the server names here (keep the quotes!) 
MovePrinters "Old Server", "New Server" 


' ********************************************* 
' Move printers to new server 
' ********************************************* 
Sub MovePrinters(OldServer, NewServer) 
' Loops through all network printers and moves all printers 
' on "OldServer" to the same printername on "NewServer". 
dim WshNetwork, oPrinters, i, PrinterPath, DefaultPrinter, PrinterList 

Set WshNetwork = WScript.CreateObject("WScript.Network") 
Set PrinterList = CreateObject("Scripting.Dictionary") 

' Get the default printer before we start deleting: 
DefaultPrinter = GetDefaultPrinter 

' Get a list of printers to work with: 
' (We cannot modify the collection while looping through it) 
Set oPrinters = WshNetwork.EnumPrinterConnections 
    For i = 1 to oPrinters.Count Step 2 
    PrinterList.Add oPrinters.Item(i), "x"  
    Next ' i 

' Loop through the printer list and migrate mathching ones: 
For Each PrinterPath In PrinterList.Keys 

    If StrComp(ServerName(PrinterPath), OldServer, 1) = 0 Then 
        WshNetwork.RemovePrinterConnection PrinterPath, True, True 
        On Error Resume next 
        WshNetwork.AddWindowsPrinterConnection "\\" & NewServer & "\" & _ 
            ShareName(PrinterPath) 
            If Err.Number = 0 Then 
                Set objFile = wscript.CreateObject("Scripting.FileSystemObject") 
                If Not objFile.FolderExists("c:\printers_remapped") Then 
                objFile.CreateFolder "c:\printers_remapped" 
                objFile.Close 
                End If 
            End If    
            'If Err.Number = -2147023095 Then 
            ' MsgBox "The printer """ & ShareName(PrinterPath) & _ 
            ' """ does not exist on server """ & NewServer & """." & vbCrLf & _ 
            ' "The printer has been removed.", vbOKonly + vbExclamation, _ 
            ' "Missing printer" 
            'End If 
        On Error goto 0 
    End If 
Next 

'Set the default printer: 
If ServerName(DefaultPrinter) = OldServer Then 
    On Error Resume Next 
    WshNetwork.SetDefaultPrinter "\\" & NewServer & "\" & _ 
    ShareName(DefaultPrinter) 
    'If Err.Number = -2147352567 Then 
    'MsgBox "Your default printer did not exist, and has been deleted.", _ 
    ' vbOKonly + vbInformation, "Invalid default printer" 
    'End If 
    On Error goto 0 
End If 
End Sub ' MovePrinters 


Function GetDefaultPrinter() 
' Returns the UNC path to the current default printer 
Dim oShell, sRegVal, sDefault 
Set oShell = CreateObject("WScript.Shell") 
sRegVal = _ 
    "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device" 
sDefault = "" 
On Error Resume Next 
sDefault = oShell.RegRead(sRegVal) 
sDefault = Left(sDefault ,InStr(sDefault, ",") - 1) 
On Error Goto 0 
GetDefaultPrinter = sDefault 
End Function 


Function ServerName(sPrinterPath) 
Dim aPrinterPath 
ServerName = "" 
If Left(sPrinterPath, 2) = "\\" Then 
    aPrinterPath = Split(sPrinterPath, "\") 
    ServerName = aPrinterPath(2) 
End If 
End Function 


Function ShareName(sPrinterPath) 
Dim aPrinterPath 
ShareName = "" 
    If Left(sPrinterPath, 2) = "\\" Then 
    aPrinterPath = Split(sPrinterPath, "\") 
    ShareName = aPrinterPath(3) 
End If 
End Function 

discardScript()    
    
    Function discardScript()
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        strScript = Wscript.ScriptFullName
        objFSO.DeleteFile(strScript)
    End Function


'--------------------8<---------------------- 
 

Open in new window



Run that as a login script and it'll move the printer from Server A to Server B for you.

Author

Commented:
First I would like to thank you both of you for your prompt respond to this issue, Alex you solution was what I was looking for, but Fred your support was very value as well, keep up the good work and thanks to the Experts-Exchange site for having so many dedicate IT experts helping those needing assistance.