$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." } }