Printer Purge almost ready to be tested

This commit is contained in:
Zachary Gorman 2024-07-03 17:00:31 -07:00
parent dbc803b1cc
commit 433d89c8b9
2 changed files with 25 additions and 0 deletions

18
Private/PrinterPurge.ps1 Normal file
View file

@ -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
}

View file

@ -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,
@ -294,6 +296,11 @@ Function Get-PC {
break
}
if ($PrinterPurge) {
Invoke-PrinterPurge $comp
continue
}
#Launches the request launcher script which containts landesk request template scripts
if ($RequestLauncher) {
Invoke-Expression \\int.samhealth.net\files\team\SHSISDesktopSolutions\Powershell\RequestLauncher\RequestLauncher.lnk