How to list all printers on network computer
15,075
Simply,
foreach (String printer in PrinterSettings.InstalledPrinters)
{
Console.WriteLine(printer.ToString()+Environment.NewLine);
}
via WMI
public static void AvailablePrinters()
{
oManagementScope = new ManagementScope(ManagementPath.DefaultPath);
oManagementScope.Connect();
SelectQuery oSelectQuery = new SelectQuery();
oSelectQuery.QueryString = @"SELECT Name FROM Win32_Printer";
ManagementObjectSearcher oObjectSearcher =
new ManagementObjectSearcher(oManagementScope, @oSelectQuery);
ManagementObjectCollection oObjectCollection = oObjectSearcher.Get();
foreach (ManagementObject oItem in oObjectCollection)
{
Console.WriteLine("Name : " + oItem["Name"].ToString()+ Environment.NewLine);
}
}
via PowerShell
Get-WMIObject -class Win32_Printer -computer $printserver | Select Name,DriverName,PortName
For more information, please check this article & WMI Printer Class
![dance2die](https://i.stack.imgur.com/dWVIl.png?s=256&g=1)
Author by
dance2die
I like to read, and build(& break?) stuff. Currently helping folks out on r/reactjs & DEV#react. Reach out to me @dance2die & check out my blog on sung.codes
Updated on June 04, 2022Comments
-
dance2die about 2 years
As shown below in the picture, when I tried to retrieve all printers, I got only 2 printers.
Is there a way to return all printers using either PowerShell WMI or C#(so that I can translate it in powershell)?
I have tried
System.Drawing.Printing.PrinterSettings.InstalledPrinters
(refer tohow to get the list of all printers in computer - C# Winform
) but also displays only 2 entries.