{"id":1472,"date":"2020-11-03T10:36:04","date_gmt":"2020-11-03T16:36:04","guid":{"rendered":"https:\/\/it.thelibrarie.com\/weblog\/?p=1472"},"modified":"2020-11-03T10:38:35","modified_gmt":"2020-11-03T16:38:35","slug":"print-server-printer-list","status":"publish","type":"post","link":"https:\/\/it.thelibrarie.com\/weblog\/2020\/11\/print-server-printer-list\/","title":{"rendered":"Print Server Printer List"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I was adding printers to our monitoring system and needed the IP addresses. Easy peasy, just check the print server, view the properties, and copy paste the IP?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">WRONG! The Canon printers were added with port names named after the printer (Canon iR-ADV 4535) and not especially helpful to my needs. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Enter Powershell! Powershell enabled computer and Office (excel) needs to be installed.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Open Powershell as Administrator<\/li><li>Run the unrestricted execution Policy<\/li><li>Create printer_finder.ps1<\/li><li>Run the PS1, type in the print server name(s)<\/li><li>Open the Excel spreadsheet<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>set-executionpolicy unrestricted\na<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;#\n.SYNOPSIS\nScript to create a Excel spreadsheet with detailed information about\nthe printers installed on the server\n.DESCRIPTION\nScript was designed to give you a good description of how your print\nserver(s) are installed and configured.\n<code>* Requires Microsoft Excel be installed on the workstation you are running the script from.<\/code>\n.PARAMETER PrintServers\nName of the server you wish to run the script again. Can also be an\narray of servers.\n.OUTPUTS\nExcel spreadsheet\n.EXAMPLE\n.\\Export-PrinterInfo.ps1 -PrintServers \"MyPrintServer\"\n.EXAMPLE\n.\\Export-PrinterInfo.ps1 -PrintServers (Get-Content c:\\scripts\\myprintserverlist.txt)\n.NOTES\nAuthor: Martin Pugh\nTwitter: @thesurlyadm1n\nSpiceworks: Martin9700\nBlog: www.thesurlyadmin.com\n<code>Changelog: 1.0 Initial Release<\/code>\n.LINK\nhttp:\/\/community.spiceworks.com\/scripts\/show\/2186-export-printer-information-to-spreadsheet\n#>\n[CmdletBinding()]\nParam (\n[Parameter(Mandatory=$true)]\n[string[]]$PrintServers = \"MyPrintServer\"\n)\nCreate new Excel workbook\nWrite-Verbose \"$(Get-Date): Script begins!\"\nWrite-Verbose \"$(Get-Date): Opening Excel\u00e2\u20ac\u00a6\"\n$Excel = New-Object -ComObject Excel.Application\n$Excel.Visible = $True\n$Excel = $Excel.Workbooks.Add()\n$Sheet = $Excel.Worksheets.Item(1)\n$Sheet.Name = \"Printer Inventory\"\n======================================================\n$Sheet.Cells.Item(1,1) = \"Print Server\"\n$Sheet.Cells.Item(1,2) = \"Printer Name\"\n$Sheet.Cells.Item(1,3) = \"Location\"\n$Sheet.Cells.Item(1,4) = \"Comment\"\n$Sheet.Cells.Item(1,5) = \"IP Address\"\n$Sheet.Cells.Item(1,6) = \"Driver Name\"\n$Sheet.Cells.Item(1,7) = \"Driver Version\"\n$Sheet.Cells.Item(1,8) = \"Driver\"\n$Sheet.Cells.Item(1,9) = \"Shared\"\n$Sheet.Cells.Item(1,10) = \"Share Name\"\n=======================================================\n$intRow = 2\n$WorkBook = $Sheet.UsedRange\n$WorkBook.Interior.ColorIndex = 40\n$WorkBook.Font.ColorIndex = 11\n$WorkBook.Font.Bold = $True\n=======================================================\nGet printer information\nForEach ($PrintServer in $PrintServers)\n{ Write-Verbose \"$(Get-Date): Working on $PrintServer\u00e2\u20ac\u00a6\"\n$Printers = Get-WmiObject Win32_Printer -ComputerName $PrintServer\nForEach ($Printer in $Printers)\n{\nIf ($Printer.Name -notlike \"Microsoft XPS*\")\n{ $Sheet.Cells.Item($intRow, 1) = $PrintServer\n$Sheet.Cells.Item($intRow, 2) = $Printer.Name\n$Sheet.Cells.Item($intRow, 3) = $Printer.Location\n$Sheet.Cells.Item($intRow, 4) = $Printer.Comment\n<code>If ($Printer.PortName -notlike \"*\\*\") { $Ports = Get-WmiObject Win32_TcpIpPrinterPort -Filter \"name = '$($Printer.Portname)'\" -ComputerName $Printserver ForEach ($Port in $Ports) { $Sheet.Cells.Item($intRow, 5) = $Port.HostAddress } } #################### $Drivers = Get-WmiObject Win32_PrinterDriver -Filter \"__path like '%$($Printer.DriverName)%'\" -ComputerName $Printserver ForEach ($Driver in $Drivers) { $Drive = $Driver.DriverPath.Substring(0,1) $Sheet.Cells.Item($intRow, 7) = (Get-ItemProperty ($Driver.DriverPath.Replace(\"$Drive`:\",\"\\\\$PrintServer\\$Drive`$\"))).VersionInfo.ProductVersion $Sheet.Cells.Item($intRow,8) = Split-Path $Driver.DriverPath -Leaf } #################### $Sheet.Cells.Item($intRow, 6) = $Printer.DriverName $Sheet.Cells.Item($intRow, 9) = $Printer.Shared $Sheet.Cells.Item($intRow, 10) = $Printer.ShareName $intRow ++ } } $WorkBook.EntireColumn.AutoFit() | Out-Null<\/code>\n}\n$intRow ++\n$Sheet.Cells.Item($intRow,1) = \"Printer inventory completed\"\n$Sheet.Cells.Item($intRow,1).Font.Bold = $True\n$Sheet.Cells.Item($intRow,1).Interior.ColorIndex = 40\n$Sheet.Cells.Item($intRow,2).Interior.ColorIndex = 40\nWrite-Verbose \"$(Get-Date): Completed!\"<\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/printer_finder.ps1\nprintservernamehere\nanotherprintservernamehereifapplicable<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I was adding printers to our monitoring system and needed the IP addresses. Easy peasy, just check the print server, view the properties, and copy paste the IP? WRONG! The Canon printers were added with port names named after the printer (Canon iR-ADV 4535) and not especially helpful to my needs. Enter Powershell! Powershell enabled &hellip; <a href=\"https:\/\/it.thelibrarie.com\/weblog\/2020\/11\/print-server-printer-list\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Print Server Printer List<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-1472","post","type-post","status-publish","format-standard","hentry","category-microsoft"],"_links":{"self":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/posts\/1472","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/comments?post=1472"}],"version-history":[{"count":3,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/posts\/1472\/revisions"}],"predecessor-version":[{"id":1475,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/posts\/1472\/revisions\/1475"}],"wp:attachment":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/media?parent=1472"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/categories?post=1472"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/tags?post=1472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}