Changing the spool directory

During the printing process, the Windows printer spooler in Windows uses an on-disk folder to hold the temporary files that have been created. If multiple users each print large documents to a single printer, the print queue can get quite large. By default, this folder is C:\Windows\System32\spool\PRINTERS. For a busy print server with multiple printers, you may wish to change the default spool folder.

Getting ready

This recipe uses the PSRV printer server that was set up as per the Installing and sharing printers recipe.

How to do it...

  1. Load the System.Printing namespace and classes:
    Add-Type -AssemblyName System.Printing
  2. Define the required permissions—that is, the ability to administrate the server:
    $Permissions = [System.Printing.PrintSystemDesiredAccess]:: ...

Get Windows Server 2019 Automation with PowerShell Cookbook - Third Edition now with the O’Reilly learning platform.

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