5

コンピューターのリスト用にインストールされているプリンターのリストを取得しようとしています。

このスクリプトを実行すると、最後のコンピューターの情報のみが「書き込まれ」ます。

私は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 
}

前もって感謝します!

4

1 に答える 1

7

使ってみてくださいOut-File -FilePath $filePath -Append

于 2012-12-19T12:16:10.047 に答える