2012-12-19 30 views
5

コンピュータの一覧のプリンタをインストールしたリストを取得しようとしています。PowerShell:テキストファイルに書き込む

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

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

ありがとうございます!

答えて

6

お試しください。Out-File -FilePath $filePath -Append

+0

Worked Great ダムのお尻のように感じていただきありがとうございます。ありがとうございました。私はまだ学んでいると思う。 – Khan

+0

ようこそ。あなたが望むなら、答えを正しいとマークすることを忘れないでください –

関連する問題