Chapter 14. PowerShell type formatting

Adam Driscoll

Type formatting is used to define how a .NET type will be displayed on the PowerShell command line or host. Without the use of formatting a large number of .NET types would prove difficult to read. This chapter focuses on defining a custom formatting file for the PrintSystemJobInfo class. This class defines the print jobs that are in progress on local and remote print servers. The following script outputs all the print jobs on the local machine:

Add-Type –AssemblyName "System.Printing"

foreach($pq in (New-Object -TypeName
   System.Printing.PrintServer).GetPrintQueues()) { $pq.Refresh() $pq.GetPrintJobInfoCollection() ...

Get PowerShell Deep Dives now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.