我正在尝试获取计算机列表的已安装打印机列表。
当我运行这个脚本时,它只会“写入”最后一台计算机的信息。
我对 PS 很陌生,希望能得到一些帮助。
$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
}
先感谢您!