Esto necesita permisos de administrador de dominio.
Para obtener las impresoras simplemente se usa Get-Printer
Get-Printer -ComputerName aprsrv04.apross.gov.ar > C:\temp\printersAPR.txt
Este script solicita credenciales e invoca una ventanita para seleccionar la impresora.
$printers = @("Afiliaciones ", "Atencion Integral ", "Atencion Integral 2 ", "Compras ", "Contabilidad ", "Contabilidad2 ", "Contratos ", "Facturacion ", "Legales1 ", "Legales2 ", "Liquidaciones ", "Medicamentos ", "Otras Prestaciones ", "Recaudaciones ", "Recursos Humanos ", "Servicios Medicos ", "Servicios Medicos 2 ", "Tesoreria ")
$selectedPrinter = $printers | Out-GridView -Title "Select a printer" -OutputMode Single
$computerName = computer.example.gov.ar
$cred = Get-Credential
Invoke-Command -ComputerName $computerName -Credential $cred -ScriptBlock {
# Check if a printer was selected
if ($selectedPrinter) {
# Use the selected printer in your script
Get-Printer -ComputerName $computerName -Name "$selectedPrinter" | %{ Get-PrintJob -PrinterName $_.Name -ComputerName $_.ComputerName | Remove-PrintJob }
}
else {
Write-Host "No printer selected."
}
}