Suspend-PrintJob
Print Management: Suspends a print job on the specified printer.
#Requires -Version 5.1
#Requires -Modules PrintManagement
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[string]$PrinterName,
[Parameter(Mandatory = $true)]
[int]$JobID,
[string]$ComputerName,
[pscredential]$AccessAccount
)
Process {
try {
if ([System.String]::IsNullOrWhiteSpace($ComputerName)) { $ComputerName = [System.Net.DNS]::GetHostByName('').HostName }
$cim = if ($null -eq $AccessAccount) { New-CimSession -ComputerName $ComputerName -ErrorAction Stop }
else { New-CimSession -ComputerName $ComputerName -Credential $AccessAccount -ErrorAction Stop }
Suspend-PrintJob -CimSession $cim -ComputerName $ComputerName -PrinterName $PrinterName -ID $JobID -ErrorAction Stop | Out-Null
Write-Output "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Print job $JobID suspended on printer $PrinterName on $ComputerName"
}
catch { throw }
finally { if ($null -ne $cim) { Remove-CimSession $cim -ErrorAction SilentlyContinue } }
}Name of the printer on which to suspend the print job.
ID of the print job to suspend.
Name of the computer on which to suspend the print job.
User account that has permission to perform this action.