Forum Discussion

trsisko unknown's avatar
trsisko unknown
Copper Contributor
Nov 09, 2023

how to tell how many printers are installed on the vm servers ?

hi there we have 15 servers hosting our printers all though azure UP obviously, just curious to know if there's a way we can run a script to see how many printers are installed on each server, i just realised our instructions for setting up a new printer via powershell script doesn't seem to install printer based on who which vm server 2019 has the least amount, running the latest connector. or by location

  • LeonPavesic's avatar
    LeonPavesic
    Silver 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.log

     

    Please 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 unknown's avatar
      trsisko unknown
      Copper Contributor
      thx 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!

Resources