How to do it...

First, let's look at how you change the spool folder using the .NET Framework:

  1. Load the System.Printing namespace and classes:
      Add-Type -AssemblyName System.Printing
  1. Define the required permissions—that is, the ability to administrate the server:
      $Permissions = 
[System.Printing.PrintSystemDesiredAccess]::
AdministrateServer
  1. Create a PrintServer object with the required permissions:
      $Ps = New-Object 
-TypeName System.Printing.PrintServer `
-ArgumentList $Permissions
  1. Update the default spool folder path:
      $Newpath = 'C:\Spool'
      $Ps.DefaultSpoolDirectory = $Newpath
  1. Commit the change:
      $Ps.Commit()
  1. Restart the Spooler to accept the new folder:
    Restart-Service -Name Spooler
  
  1. Once the Spooler has restarted, view the results:
      New-Object -TypeName System.Printing.PrintServer |
          Format-Table -Property Name, 
DefaultSpoolDirectory

Another way to set the Spooler directory is by directly editing the registry as follows:

  1. First stop the Spooler service:
      Stop-Service -Name Spooler
  1. Set the spool directory registry setting:
      PS C:\foo> $RPath    = 'HKLM:\SYSTEM\CurrentControlSet\Control\ +
Print\Printers'
$Spooldir = 'C:\SpoolViaRegistry' Set-ItemProperty -Path $RPath ` -Name DefaultSpoolDirectory ` -Value 'C:\SpoolViaRegistry'
  1. Restart the Spooler:
       Start-Service -Name Spooler
  1. View the results:
       New-Object -TypeName System.Printing.PrintServer |
           Format-Table -Property Name, 
DefaultSpoolDirectory