Forum Discussion
- LeonPavesicSilver Contributor
Hi trsisko unknown,
there is a way you can try to use a script to see how many printers are installed on each VM server.
Here is a PowerShell script that you can use:# Get a list of all servers $servers = Get-VM # Get a list of all printers on each server foreach ($server in $servers) { $printers = Get-Printer -ComputerName $server # Count the number of printers $count = $printers.Count # Write the number of printers to a log file Add-Content -Path "C:\PrinterCount.log" -Value "$server has $count printers installed." }
Here’s how it works:
- It first retrieves a list of all servers using the Get-VM command.
- Then, for each server in the list, it retrieves a list of all printers installed on that server using the Get-Printer -ComputerName $server command.
- It counts the number of printers using the .Count property of the list of printers.
- Finally, it writes the number of printers installed on each server to a log file located at C:\PrinterCount.logPlease click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.If the post was useful in other ways, please consider giving it Like.
Kindest regards,
Leon Pavesic
(LinkedIn)- trsisko unknownCopper Contributorthx I actually realised our script distributes the creation of new printers across the servers so it's the same amount after doing a Get-printer list from several of the servers, but thanks looks good!
- Saurabh_BansalMicrosoft
trsisko unknown If printers are registered with Universal Print, you can also use the Microsoft Graph PowerShell module to create a script.
Some APIs that may help:
- List printConnectors - Microsoft Graph v1.0 | Microsoft Learn
- List printers - Microsoft Graph v1.0 | Microsoft Learn
For printer, if it's registered via a Connector, then you can get its connector information from the printer object.