I am trying to get a list installed printers for a list of computer.
When I run this script, it only "writes" the last computer's information.
I am VERY new to PS and would appreciate some help.
$filePath = "E:\ps\computerswithprinters.txt"
$class = "win32_printer"
$arycomputer = Get-Content "E:\ps\computers.txt"
foreach( $computer in $aryComputer)
{
Write-Host "Retrieving printers from $computer ..."
$wmi = Get-WmiObject -Class $class -computername $computer
format-table -Property name, systemName, shareName -groupby driverName `
-inputobject $wmi -autosize | Out-File -FilePath $filePath
}
Thank you in advance!
Try using Out-File -FilePath $filePath -Append
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With