This weekend I found myself in a situation where I needed to find print server information, such as the default spool directory and restart job timeout value.
You can use the System.Printing assembly for that.
Here’s a function that provides you some basic print server information:
function Get-PrintServerInformation { param ( [parameter(mandatory=$false,position=0,valuefrompipelinebypropertyname=$true,valuefrompipeline=$true)][string[]]$ComputerName=$Env:COMPUTERNAME ) begin { Add-Type -AssemblyName system.printing } process { $ComputerName | foreach { New-Object System.Printing.PrintServer("\\$_",'AdministrateServer') } } end { } }
And here’s the output:
Name : \\minimonster SubSystemVersion : 0 RestartJobOnPoolEnabled : True RestartJobOnPoolTimeout : 600 MinorVersion : 0 MajorVersion : 3 EventLog : LogPrintingErrorEvents NetPopup : False BeepEnabled : False DefaultSchedulerPriority : Normal SchedulerPriority : Normal DefaultPortThreadPriority : Normal PortThreadPriority : Normal DefaultSpoolDirectory : C:\Windows\system32\spool\PRINTERS Parent : PropertiesCollection : {DefaultPortThreadPriority, EventLog, Name, RestartJobOnPoolTimeout...}