cannot export output of this script to a file??

by Dec 21, 2011

Hello,

We are using underneath script to gather some printer information. It works well, but I can't figure it out how to export or write this output to an external file.
I've tried also with Out-file but didn't work?

I know it's a very newbee, maybe even dumb question but it would help me a lot if someone could help me on this.

Many thanks!!!

 

$strComputer = "."

$colItems = get-wmiobject -class "Win32_Printer" -namespace "rootCIMV2" `
-computername $strComputer

foreach ($objItem in $colItems) {
      write-host "Caption: " $objItem.Caption
      write-host "Comment: " $objItem.Comment
      write-host "Device ID: " $objItem.DeviceID
      write-host "Location: " $objItem.Location
      write-host "Name: " $objItem.Name
      write-host "Port Name: " $objItem.PortName
      write-host "Print Processor: " $objItem.PrintProcessor
      write-host "Server Name: " $objItem.ServerName
      write-host "Shared: " $objItem.Shared
      write-host "Share Name: " $objItem.ShareName
      write-host "System Name: " $objItem.SystemName
      write-host
}