Windows Vista Forums

-f format Format-Table Format-List against Select

  1. #1


    Personne Guest

    -f format Format-Table Format-List against Select

    For some reason I need to rename a column within a select

    Get-WmiObject win32_SystemEnclosure -ComputerName SD-IT003
    it returns SerialNumber

    But I do not like this label, I want to rename it

    so
    Get-WmiObject win32_SystemEnclosure -ComputerName $p | ft @{Expression=
    {$_.SerialNumber};Label="SN"}
    --> This works really well, but instead of renaming the column in FT,
    I need to rename it during a select

    So I tried this:

    Get-WmiObject win32_SystemEnclosure -ComputerName $p | select @
    {Expression={$_.SerialNumber};Label="SN"} | ft *

    but it returns
    Select-Object : Illegal key Label
    At line:1 char:61
    + Get-WmiObject win32_SystemEnclosure -ComputerName $p| select <<<< @
    {Expression={$_.SerialNumber};Label="SN"}

    Why is that ? is there a way to fix it ?



      My System SpecsSystem Spec

  2. #2


    Personne Guest

    Re: -f format Format-Table Format-List against Select

    My goal is to do this

    $p=get-qadcomputer -name sd-*
    $p | foreach {
    gwmi win32_operatingsystem -ComputerName $_.name | select
    CSName,caption,CSDVersion,version,Description,SerialNumber
    #gwmi Win32_WindowsProductActivation -ComputerName $_.name | select
    ProductID
    gwmi Win32_ComputerSystem -ComputerName $_.name | select
    Domain,Manufacturer,Model,UserName
    gwmi win32_bios -ComputerName $_.name | select SerialNumber
    gwmi win32_SystemEnclosure -ComputerName $_.name | select SerialNumber
    } | ft *

    but as you can see I do have 3 requests returning a Serialnumber, but
    I would like to return a table with SN1,SN2 and SN3



      My System SpecsSystem Spec

  3. #3


    Hal Rottenberg [MVP] Guest

    Re: -f format Format-Table Format-List against Select

    Personne wrote:

    > --> This works really well, but instead of renaming the column in FT,
    > I need to rename it during a select
    >
    > So I tried this:
    >
    > Get-WmiObject win32_SystemEnclosure -ComputerName $p | select @
    > {Expression={$_.SerialNumber};Label="SN"} | ft *
    The Select-Object cmdlet uses the key "Name" instead of "Label". I struggled a
    long time with the logic of this and eventually squared it with my brain by
    referring to the fields created by Select-Object as "real properties" and
    properties have names, as opposed to Format-* which is merely for display
    purposes, so "label" implies a more temporary connotation.

    HTH

    --
    $signature = "Hal Rottenberg, MVP - Admin Frameworks"
    $projects = @{ title = "Blog Author"; url = "http://halr9000.com" },
    @{ title = "Co-host"; url = "http://powerscripting.net" },
    @{ title = "Community Director"; url = "http://PowerShellCommunity.org" },
    @{ title = "Psi Webmaster"; url = "http://psi-im.org" }

      My System SpecsSystem Spec

  4. #4


    Personne Guest

    Re: -f format Format-Table Format-List against Select

    $p="."
    $with_label = @{Expression={$_.SerialNumber};Label="SN1"}
    $with_name = @{Expression={$_.SerialNumber};Name="SN2"}

    gwmi win32_SystemEnclosure -ComputerName $p | ft $with_label
    gwmi win32_SystemEnclosure -ComputerName $p | select $with_name

    Works Perfect
    Thank you

      My System SpecsSystem Spec

  5. #5


    OldDog Guest

    Re: -f format Format-Table Format-List against Select

    On Nov 24, 1:01*pm, Personne <cpdiv...@xxxxxx> wrote:

    > $p="."
    > $with_label = @{Expression={$_.SerialNumber};Label="SN1"}
    > $with_name = @{Expression={$_.SerialNumber};Name="SN2"}
    >
    > gwmi win32_SystemEnclosure -ComputerName $p | ft $with_label
    > gwmi win32_SystemEnclosure -ComputerName $p | select $with_name
    >
    > Works Perfect
    > Thank you
    You must be working with Dell computers,
    for HP and IBM's you have to look in Win32_BIOS for the SerialNumber
    or Win32_ComputerSystemProduct for the IdentifyingNumber

    1# gwmi Win32_ComputerSystemProduct


    IdentifyingNumber : MXL60207Q5
    Name : HP Compaq dc7600 Small Form Factor
    Vendor : Hewlett-Packard
    Version :
    Caption : Computer System Product



    2# gwmi Win32_BIOS


    SMBIOSBIOSVersion : 786D1 v01.03
    Manufacturer : Hewlett-Packard
    Name : Default System BIOS
    SerialNumber : MXL60207Q5
    Version : COMPAQ - 20050518





    OldDog

      My System SpecsSystem Spec

  6. #6


    OldDog Guest

    Re: -f format Format-Table Format-List against Select

    On Nov 24, 1:01*pm, Personne <cpdiv...@xxxxxx> wrote:

    > $p="."
    > $with_label = @{Expression={$_.SerialNumber};Label="SN1"}
    > $with_name = @{Expression={$_.SerialNumber};Name="SN2"}
    >
    > gwmi win32_SystemEnclosure -ComputerName $p | ft $with_label
    > gwmi win32_SystemEnclosure -ComputerName $p | select $with_name
    >
    > Works Perfect
    > Thank you
    I have found that I need to use win32_SystemEnclosure for Dell Servers

    HP servers will give you the serial number in three different places;

    gwmi Win32_BIOS -computername server1
    as SerialNumber

    Or

    gwmi Win32_ComputerSystemProduct -computername Server1

    as IdentifyingNumber

    as well as

    gwmi win32_SystemEnclosure -computername Server1
    as SerialNumber

    OldDog

      My System SpecsSystem Spec

-f format Format-Table Format-List against Select

Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows Mail format bar doesn't format color, size, justification Marge90601 Browsers & Mail 0 13 Nov 2008
RE: How to convert Table-Format Data to CSV-Format? Kiron PowerShell 0 25 Jul 2008
RE: How to convert Table-Format Data to CSV-Format? Kiron PowerShell 0 25 Jul 2008
RE: How to convert Table-Format Data to CSV-Format? Kiron PowerShell 0 25 Jul 2008
Help! DVD format error: "Windows was unable to complete the format hamishmacdonald Vista General 13 29 Mar 2007