<!-- wp:paragraph -->
<p>We get asked fairly often if it's possible to quickly delete printers from PaperCut. You could do it the old fashioned way (you know, manually) but why would you want to do that - you have a coffee to drink! ;-)</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>There is already a handy <a href="https://www.papercut.com/kb/Main/BatchDeletingPrinters">KB article</a> available from PaperCut which covers one way to do this... But, as you know we like to be a bit different - so, to make life a tad easier we have a couple of scripts that we use, and thought we'd share them with you.<br></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Why might you want to delete printers en masse?</strong></p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li>You might have multiple printers that you need to delete, and little time to do it</li><li>You didn't know that there was an “ignore printers” option when you added the devices to PaperCut</li></ul>
<!-- /wp:list -->

<!-- wp:spacer {"height":50} -->
<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

<!-- wp:heading {"level":3,"align":"left"} -->
<h3 style="text-align:left">How to delete printers in bulk</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>This is the way to remove printers in bulk that we like to use, which works in most scenarios. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Go to Printers and click on the CSV/Excel icon at the bottom of the page - delete the first 2 lines and any lines which contain the printers that you'd like to keep, so the file will only contain a list of the printers you want to remove.<br></p>
<!-- /wp:paragraph -->

<!-- wp:spacer {"height":50} -->
<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

<!-- wp:image {"id":6771} -->
<figure class="wp-block-image"><img src="https://staging.selectec.com/wp-content/uploads/2019/04/download_printer_list-1.gif" alt="" class="wp-image-6771"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Update the serverCommand and csvPath in the script and give it a run.<br></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Powershell</strong></p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="">CLS

$serverCommand = 'C:\Program Files\PaperCut MF\server\bin\win\server-command.exe'
$csvPath = 'C:\temp\printer_list.csv'

$csvData = Import-CSV $csvPath -Header server,printer

ForEach ($printer in $csvData) {
    &amp;$serverCommand delete-printer $printer.server $printer.printer
}
</pre>
<!-- /wp:html -->

<!-- wp:paragraph -->
<p><strong>Bash</strong></p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="">
#!/bin/bash

serverCommand=/home/papercut/server/bin/linux-x64/server-command
csvPath=/home/papercut/temp/printer_list.csv

while IFS="," read -r serverName printerName theRest
do
        "${serverCommand}" delete-printer $serverName $printerName
done < $csvPath
</pre>
<!-- /wp:html -->

<!-- wp:spacer {"height":50} -->
<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

<!-- wp:heading {"level":3,"align":"left"} -->
<h3 style="text-align:left">The other way to delete printers in bulk...</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The same process can be used to remove devices if needed but instead of exporting the list of printers you would go to <strong>Devices</strong>, click the CSV/Excel icon at the bottom, remove the top two lines and any devices you'd like to keep, then use the script below.<br></p>
<!-- /wp:paragraph -->

<!-- wp:spacer {"height":50} -->
<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

<!-- wp:image {"id":7462} -->
<figure class="wp-block-image"><img src="https://staging.selectec.com/wp-content/uploads/2019/06/download_device_list-1.gif" alt="" class="wp-image-7462"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p> <strong>Powershell</strong></p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="">CLS

$serverCommand = 'C:\Program Files\PaperCut MF\server\bin\win\server-command.exe'
$csvPath = 'C:\temp\device_list.csv'

$csvData = Import-CSV $csvPath -Header device

ForEach ($device in $csvData) {
        &amp;$serverCommand delete-printer ($device.device -split '\\')[0] ($device.device -split '\\')[1]
}
</pre>
<!-- /wp:html -->

<!-- wp:paragraph -->
<p><strong>Bash</strong></p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="">
#!/bin/bash

serverCommand=/home/papercut/server/bin/linux-x64/server-command
csvPath=/home/papercut/temp/device_list.csv

while IFS="," read -r device theRest
do
        $serverCommand delete-printer $(echo $device | cut -d "\\" -f 1) $(echo $device | cut -d "\\" -f 2)
done < $csvPath
</pre>
<!-- /wp:html -->

<!-- wp:spacer {"height":50} -->
<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

<!-- wp:heading {"level":4,"align":"left"} -->
<h4 style="text-align:left">We hope you find this useful! Remember, if you need custom scripts for PaperCut <a href="https://staging.selectec.com/contact/">get in touch</a> with the team!</h4>
<!-- /wp:heading -->