コンピューターのリスト用にインストールされているプリンターのリストを取得しようとしています。
このスクリプトを実行すると、最後のコンピューターの情報のみが「書き込まれ」ます。
私は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
}
前もって感謝します!