O'Reilly logo

PowerShell Deep Dives by Edited by Jeffery Hicks, Richard Siddaway, Oisín Grehan, and Aleksandar Nikoli

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required