I need a PS script that can list all installed printers using a list of computers. Something like what this script does but for more than 1 computer:Get-WmiObject -class Win32_printer| ft name, systemName, shareName >> C:\result.txt
You don't actually need much of a script for that, since the Get-WmiObject cmdlet supports the -ComputerName parameter you could iterate through a list of computer names stored in a text file using something along these lines:
Thank you very much! It saved me a lot of time!
Not a problem at all, ForEach-Object is very useful for these kind of tasks. You might run into some timeout issues using the script as I provided it, nothing serious but if a computer cannot be contacted via WMI it will wait for a timeout before deciding to check the next system. If you will be running the script as-is against a large number of computers with many of them offline it might take a while for the script to complete.
Indeed very useful. Some of our computers are offline and as you said it took sometime but it did the job for the computers that were online!
Alright, so the next example I have added a Test-Connection cmdlet in there to first ping the system before attempting to establish a wmi connection. Have a look at the results by running this code:
Nice addition, thank you! [:)]. I tested it this time on some 300 computers & it takes less 3 minutes to finish including the offline computers in the result file. By the way I think a bracket is missing just before the Else statement.
That is correct, I missed that one when I was writing the code, thanks for the correction! I have updated the code in the previous post.
That was a great addition i was able to use the script at my job as well to see what machines need the extra printer thanks for the question and the solution.
After 5 years . . . thank you for this