Create printer inventory with PowerShell

How to create a printer inventory from multiple print servers with PowerShell.

$servers = Get-Content "%temp%\serverlist.txt" # TXT should contain one FQDN per line
$Date = Get-Date -format
$CSV= "%temp%\Printers $date.csv"
$allprinters = @()
foreach( $server in $servers ){
Write-Host "checking $server ..."
$printer = $null
$printers = $null
$printers = Get-WmiObject -class Win32_Printer -computername $server -Credential $MyCredential # Credentials are optional
$printer = $printers | where-object {$_.shared}
$allprinters += $printer
Write-Host "exporting to printers.csv"
$allprinters | select-object name, sharename, printerstatus, DriverName, PortName, SystemName, Location |`
ogv -PassThru | Export-CSV $CSV -NoTypeInformation -Encoding UTF8
Write-Host -ForegroundColor Green "Printers are successfully exported"