Windows Vista Forums

Format-Table output ?

  1. #1


    Russell Guest

    Format-Table output ?

    Hello,

    In the script below how do I output the $objItem.Name and
    $objItem.DriverName
    using Format-Table instead of write-host or do I need to somehow use both?

    Thanks.


    $strComputer = "."

    $colItems = get-wmiobject -class "Win32_Printer" -namespace
    "root\CIMV2" -computername $strComputer

    foreach ($objItem in $colItems)
    {
    write-host $objItem.Name $objItem.DriverName
    write-host
    }


      My System SpecsSystem Spec

  2.   


  3. #2


    PaulChavez Guest

    RE: Format-Table output ?

    Try this:

    get-wmiobject -class "Win32_Printer" | format-table Name,DriverName

    Localhost and roo\CimV2 are defaults for get-wmiobject.

    "Russell" wrote:

    > Hello,
    >
    > In the script below how do I output the $objItem.Name and
    > $objItem.DriverName
    > using Format-Table instead of write-host or do I need to somehow use both?
    >
    > Thanks.
    >
    >
    > $strComputer = "."
    >
    > $colItems = get-wmiobject -class "Win32_Printer" -namespace
    > "root\CIMV2" -computername $strComputer
    >
    > foreach ($objItem in $colItems)
    > {
    > write-host $objItem.Name $objItem.DriverName
    > write-host
    > }
    >

      My System SpecsSystem Spec

  4. #3


    Russell Guest

    Re: Format-Table output ?

    Thank you. That's what I was looking for.


    "PaulChavez" <PaulChavez@newsgroup> wrote in message
    news:4B3D05E9-E81F-4079-909C-37A475A1CD9B@newsgroup

    > Try this:
    >
    > get-wmiobject -class "Win32_Printer" | format-table Name,DriverName
    >
    > Localhost and roo\CimV2 are defaults for get-wmiobject.
    >
    > "Russell" wrote:
    >

    >> Hello,
    >>
    >> In the script below how do I output the $objItem.Name and
    >> $objItem.DriverName
    >> using Format-Table instead of write-host or do I need to somehow use
    >> both?
    >>
    >> Thanks.
    >>
    >>
    >> $strComputer = "."
    >>
    >> $colItems = get-wmiobject -class "Win32_Printer" -namespace
    >> "root\CIMV2" -computername $strComputer
    >>
    >> foreach ($objItem in $colItems)
    >> {
    >> write-host $objItem.Name $objItem.DriverName
    >> write-host
    >> }
    >>

      My System SpecsSystem Spec


Format-Table output ?
Similar Threads
Thread Forum
-f format Format-Table Format-List against Select PowerShell
RE: How to convert Table-Format Data to CSV-Format? PowerShell
RE: How to convert Table-Format Data to CSV-Format? PowerShell
RE: How to convert Table-Format Data to CSV-Format? PowerShell
[demo] Format-Chart - Formats output as a table with a chart colum PowerShell