$ErrorActionPreference = 'Stop' $log = New-Item -ItemType Directory -Force postscript-inventory $system = Get-CimInstance Win32_OperatingSystem @( "ImageOS=$env:ImageOS" "ImageVersion=$env:ImageVersion" "Windows=$($system.Caption)" "Version=$($system.Version)" ) | Set-Content -LiteralPath (Join-Path $log.FullName 'system.txt') Start-Service Spooler Get-PrinterDriver | Select-Object Name, Manufacturer, MajorVersion, PrinterEnvironment | ConvertTo-Json -AsArray | Set-Content -LiteralPath (Join-Path $log.FullName 'registered-drivers.json') # DISM distinguishes drivers furnished with the OS from other packages. Read # only printer INFs inside the local Driver Store without changing the packages. $store = Join-Path $env:SystemRoot 'System32\DriverStore\FileRepository' $packages = @(Get-WindowsDriver -Online -All | Where-Object { $_.Inbox -and $_.ClassName -eq 'Printer' }) $packages | Select-Object Driver, OriginalFileName, ProviderName, Inbox, Version | ConvertTo-Json -AsArray | Set-Content -LiteralPath (Join-Path $log.FullName 'inbox-printer-packages.json') $evidence = foreach ($package in $packages) { $inf = $package.OriginalFileName if (!$inf -or !$inf.StartsWith("$store\", [StringComparison]::OrdinalIgnoreCase) -or !(Test-Path -LiteralPath $inf -PathType Leaf)) { continue } $models = @(Select-String -LiteralPath $inf -Pattern 'PostScript|PSCRIPT5|PS Class Driver|Imagesetter' | ForEach-Object { $_.Line.Trim() } | Sort-Object -Unique) if ($models.Count) { [pscustomobject]@{ Driver = $package.Driver Inf = $inf Provider = $package.ProviderName Entries = $models } } } @($evidence) | ConvertTo-Json -AsArray -Depth 4 | Set-Content -LiteralPath (Join-Path $log.FullName 'postscript-infs.json') Get-Content -LiteralPath (Join-Path $log.FullName 'system.txt') Get-Content -LiteralPath (Join-Path $log.FullName 'registered-drivers.json') foreach ($match in $evidence) { Write-Output "$($match.Driver) / $($match.Provider)" $match.Entries | Select-Object -First 30 | Write-Output }