18 lines
835 B
PowerShell
18 lines
835 B
PowerShell
# Removes printer from all online computers. Useful when printer drivers
|
|
# change to force users to install new drivers
|
|
function Invoke-PrinterPurge ($printer) {
|
|
$comps = HostnamesByPrinter($printer)
|
|
# confirm step?
|
|
for ($i = 0; $i -lt $comps.Length; $i += 1) {
|
|
$comp = $comps[$i]
|
|
Write-Progress -Activity "Dispatching Remove-Printer Jobs for $printer" -PercentComplete (100*$i / $comps.Length) -CurrentOperation $comp
|
|
if ($comp -like "*EPIC*") { continue }
|
|
if (-not (Test-Connection $comp -Count 1)) {
|
|
Write-Output "$printer | $comp Offline"
|
|
continue
|
|
}
|
|
# Remove-Printer $printer -ComputerName $comp -AsJob
|
|
Write-Output "$printer | $comp Job Sent"
|
|
}
|
|
Write-Progress -Activity "Dispatching Remove-Printer Jobs for $printer" -Completed
|
|
} |