I am new to Powershell. I am trying to figure to remove remotely all printers on a workstation/domain user. I have to do this on 100+ computers.
I have written a small script where I get the list of all computers and printers on a domain. Group policy was already removed and the printer disappeared but some users have installed/mapped the printers from the print server (shared) and some have also installed local printers. Somehow the script does not show them. I ran is admin and the highest level of domain administrator no luck. I cannot believe that as an administrator I cannot see or delete those printers via power shell.GP
See the script for making a list of which printer is installed on which computer. I will modify the result then delete those printers. Like mention shared and local printers do not show up. If ran this script as the users all printers are listed
Get-Content -Path c:\ListOfComputers.txt | ForEach-Object { if (Test-Connection $_ -Count 1 -Quiet) { Get-WMIObject WIN32_Printer -ComputerName $_ | Select-Object -Property Systemname,Location,Name,Printerstate,Printerstatus,Sharename | Export-Csv -Path c:\PCPrinterList.csv -NoTypeInformation -Append } else { "Computer $_ offline" >> c:\OfflinePCs.txt } }This scripts would remove the printers according to list. I tried for example to delete a mapped or shared printer but that does work.
Import-Csv c:\PCPrinterList.csv |` ForEach-Object { Remove-Printer -ComputerName $_.ComputerName -Name $_.Name }
Any idea how can get it done in powershell?
Indian