#Requires -Version 5.1 <# JbTecWiz Support Centre -- read-only diagnostic Fault : Printing from Office fails, prints blank, or goes to the wrong printer Source: https://jbtecwiz.com/support/win-office-printing This script CHANGES NOTHING. It runs only the inspection commands from the write-up -- the Get-, Test- and Resolve- calls that establish which cause is in play -- and prints what each returned. Anything that writes, deletes, starts or stops is excluded by construction, not by judgement. Read the output alongside the write-up, then pick the fix that matches. Each fix has its own script on the same page. #> [CmdletBinding()] param([switch]$Transcript) $ErrorActionPreference = 'Continue' if ($Transcript) { $log = Join-Path $env:USERPROFILE ("jbtecwiz-win-office-printing-" + (Get-Date -Format yyyyMMdd-HHmmss) + ".txt") Start-Transcript -Path $log | Out-Null Write-Host (' Saving a transcript to ' + $log) } function Write-Rule { param([string]$Text) Write-Host '' Write-Host ('-' * 70) -ForegroundColor DarkGray if ($Text) { Write-Host $Text -ForegroundColor Cyan } } function Probe { param([string]$Label, [string]$Fix, [scriptblock]$Command) Write-Rule (" " + $Label) Write-Host (" from: " + $Fix) -ForegroundColor DarkGray Write-Host '' foreach ($l in ($Command.ToString().Trim() -split "`n")) { Write-Host (" " + $l.Trim()) -ForegroundColor DarkGreen } Write-Host '' try { $out = & $Command 2>&1 | Out-String if ([string]::IsNullOrWhiteSpace($out)) { Write-Host ' (returned nothing)' -ForegroundColor DarkGray } else { foreach ($l in ($out.TrimEnd() -split "`n")) { Write-Host (" " + $l.TrimEnd()) } } } catch { Write-Host (" could not run: " + $_.Exception.Message) -ForegroundColor Yellow } } Write-Rule Write-Host ' Printing from Office fails, prints blank, or goes to the wrong printer' -ForegroundColor White Write-Host ' Read-only diagnostic -- nothing is changed.' -ForegroundColor Green Write-Rule Probe -Label 'See what Windows currently thinks the default is.' -Fix 'Pin the default printer and stop Windows moving it' -Command { Get-CimInstance Win32_Printer | Where-Object Default -eq $true | Select-Object Name, PortName, WorkOffline } Probe -Label 'Check whether Windows is managing the default itself.' -Fix 'Pin the default printer and stop Windows moving it' -Command { Get-ItemProperty 'HKCU:\Software\Microsoft\Windows NT\CurrentVersion\Windows' -Name LegacyDefaultPrinterMode -ErrorAction SilentlyContinue } Probe -Label 'Check no printer is stuck in the offline state, which makes Office behave as though it does not exist.' -Fix 'Pin the default printer and stop Windows moving it' -Command { Get-Printer | Select-Object Name, PrinterStatus, @{n='Offline';e={(Get-CimInstance Win32_Printer -Filter "Name='$($_.Name)'").WorkOffline}} } Probe -Label 'Look at what is queued before clearing it, so you know what will be lost.' -Fix 'Clear the print queue and restart the spooler' -Command { Get-Printer | ForEach-Object { Get-PrintJob -PrinterName $_.Name -ErrorAction SilentlyContinue } | Select-Object PrinterName, Id, DocumentName, SubmittedTime, JobStatus } Probe -Label 'Verify: The spooler is running, the queue is empty, and a test page prints.' -Fix 'Clear the print queue and restart the spooler' -Command { Get-Service Spooler | Select-Object Status } Probe -Label 'List what driver the printer is using.' -Fix 'Isolate the driver' -Command { Get-Printer | Select-Object Name, DriverName, PortName } Write-Rule Write-Host ' Diagnostic finished. Nothing was changed.' -ForegroundColor Green Write-Host '' Write-Host ' Compare the output above with the write-up, then run the' Write-Host ' script for the fix that matches:' Write-Host ' https://jbtecwiz.com/support/win-office-printing' Write-Rule if ($Transcript) { Stop-Transcript | Out-Null }