diff --git a/Private/PrinterPurge.ps1 b/Private/PrinterPurge.ps1 new file mode 100644 index 0000000..254290e --- /dev/null +++ b/Private/PrinterPurge.ps1 @@ -0,0 +1,18 @@ +# 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 +} \ No newline at end of file diff --git a/Public/Get-PC.ps1 b/Public/Get-PC.ps1 index 5105d2c..c6778ab 100644 --- a/Public/Get-PC.ps1 +++ b/Public/Get-PC.ps1 @@ -56,6 +56,7 @@ Function Get-PC { -RequestLauncher | starts request launcher -ResetRepository | remotely resets repository -Resources | more details about system resources + -PrinterPurge | removes printer from all online computers -SCCM | queries sccm for the computer information -SHSPrinter | pulls data about a printer using snmp -SHSPrinterweb | pulls data about a printer and opens web interface and orion @@ -105,6 +106,7 @@ Function Get-PC { [Switch]$RequestLauncher, [Switch]$Resources, [Switch]$ResetRepository, + [Switch]$PrinterPurge, [Switch]$SCCM, [Switch]$SHSPrinter, [switch]$SHSPrinterWeb, @@ -293,6 +295,11 @@ Function Get-PC { } break } + + if ($PrinterPurge) { + Invoke-PrinterPurge $comp + continue + } #Launches the request launcher script which containts landesk request template scripts if ($RequestLauncher) {