Windows Vista Forums

Select-Object in PS1 Script Bug?!
  1. #1


    BiswangerG Guest

    Select-Object in PS1 Script Bug?!

    Hello,



    i have the PowerShell V2 (CTP) and have createt a ps1 script with more
    Select-Object commands. The first command with Select-Object is Okay, the
    secend Command with Select-Object works not correkt.

    z.B. from script:

    Get-WmiObject Win32_ComputerSystem -computername $applikationserver |
    Select-Object Name, Manufacturer, model
    Get-WmiObject Win32_ComputerSystem -computername $databaseserver |
    Select-Object Name, Manufacturer, model

    the PowerShell Shows only from first Name, Manufacturer, model... with the
    secend shows name without manufacturerer, model...

    what is the problem here?






      My System SpecsSystem Spec

  2. #2


    Shay Levi Guest

    Re: Select-Object in PS1 Script Bug?!

    What happens when you run the command locally on $databaseserver?

    Get-WmiObject Win32_ComputerSystem -computername | Select-Object Name, Manufacturer,
    model

    I can't tell for sure, happend to me before, but maybe those properties aren't
    implemented on the $databaseserver machine.


    -----
    Shay Levi
    $cript Fanatic
    http://scriptolog.blogspot.com
    Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic



    > Hello,
    >
    > i have the PowerShell V2 (CTP) and have createt a ps1 script with more
    > Select-Object commands. The first command with Select-Object is Okay,
    > the secend Command with Select-Object works not correkt.
    >
    > z.B. from script:
    >
    > Get-WmiObject Win32_ComputerSystem -computername $applikationserver |
    > Select-Object Name, Manufacturer, model Get-WmiObject
    > Win32_ComputerSystem -computername $databaseserver | Select-Object
    > Name, Manufacturer, model
    >
    > the PowerShell Shows only from first Name, Manufacturer, model... with
    > the secend shows name without manufacturerer, model...
    >
    > what is the problem here?
    >


      My System SpecsSystem Spec

  3. #3


    Andrey Nepomnyaschih Guest

    Re: Select-Object in PS1 Script Bug?!

    I don't think this has something to do with PowerShell. It is the WMI
    provider which can't find the information inside SMBIOS.

    Most likely the $databaseserver server simply doesn't have this
    information stored.

    BiswangerG пишет:

    > Hello,
    >
    > i have the PowerShell V2 (CTP) and have createt a ps1 script with more
    > Select-Object commands. The first command with Select-Object is Okay, the
    > secend Command with Select-Object works not correkt.
    >
    > z.B. from script:
    >
    > Get-WmiObject Win32_ComputerSystem -computername $applikationserver |
    > Select-Object Name, Manufacturer, model
    > Get-WmiObject Win32_ComputerSystem -computername $databaseserver |
    > Select-Object Name, Manufacturer, model
    >
    > the PowerShell Shows only from first Name, Manufacturer, model... with the
    > secend shows name without manufacturerer, model...
    >
    > what is the problem here?
    >
    >
    >
    >
    >

      My System SpecsSystem Spec

  4. #4


    Shay Levi Guest

    Re: Select-Object in PS1 Script Bug?!


    Forgot to ask, is the output the same on PowerShell v1.0?

    Alternatively try:

    Get-WmiObject Win32_bios




    -----
    Shay Levi
    $cript Fanatic
    http://scriptolog.blogspot.com
    Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic



    > What happens when you run the command locally on $databaseserver?
    >
    > Get-WmiObject Win32_ComputerSystem -computername | Select-Object
    > Name, Manufacturer, model
    >
    > I can't tell for sure, happend to me before, but maybe those
    > properties aren't implemented on the $databaseserver machine.
    >
    > -----
    > Shay Levi
    > $cript Fanatic
    > http://scriptolog.blogspot.com
    > Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic

    >> Hello,
    >>
    >> i have the PowerShell V2 (CTP) and have createt a ps1 script with
    >> more Select-Object commands. The first command with Select-Object is
    >> Okay, the secend Command with Select-Object works not correkt.
    >>
    >> z.B. from script:
    >>
    >> Get-WmiObject Win32_ComputerSystem -computername $applikationserver |
    >> Select-Object Name, Manufacturer, model Get-WmiObject
    >> Win32_ComputerSystem -computername $databaseserver | Select-Object
    >> Name, Manufacturer, model
    >>
    >> the PowerShell Shows only from first Name, Manufacturer, model...
    >> with the secend shows name without manufacturerer, model...
    >>
    >> what is the problem here?
    >>


      My System SpecsSystem Spec

  5. #5


    BiswangerG Guest

    Re: Select-Object in PS1 Script Bug?!

    No, this was a example...

    this the self problem as script:

    01 get-process | select-object name, cpu
    02 get-process | select-object name, cpu

    the line 02 show only the name and not cpu... whenn i write this manuel in
    PowerShell is all okay.... as script not work.

    "Andrey Nepomnyaschih" wrote:

    > I don't think this has something to do with PowerShell. It is the WMI
    > provider which can't find the information inside SMBIOS.
    >
    > Most likely the $databaseserver server simply doesn't have this
    > information stored.
    >
    > BiswangerG пишет:

    > > Hello,
    > >
    > > i have the PowerShell V2 (CTP) and have createt a ps1 script with more
    > > Select-Object commands. The first command with Select-Object is Okay, the
    > > secend Command with Select-Object works not correkt.
    > >
    > > z.B. from script:
    > >
    > > Get-WmiObject Win32_ComputerSystem -computername $applikationserver |
    > > Select-Object Name, Manufacturer, model
    > > Get-WmiObject Win32_ComputerSystem -computername $databaseserver |
    > > Select-Object Name, Manufacturer, model
    > >
    > > the PowerShell Shows only from first Name, Manufacturer, model... with the
    > > secend shows name without manufacturerer, model...
    > >
    > > what is the problem here?
    > >
    > >
    > >
    > >
    > >
    >

      My System SpecsSystem Spec

  6. #6


    BiswangerG Guest

    Re: Select-Object in PS1 Script Bug?!

    this is a better example...

    this as script not working correct:

    get-process | select-object cpu, name
    dir | Select-Object name, length


    "BiswangerG" wrote:

    > No, this was a example...
    >
    > this the self problem as script:
    >
    > 01 get-process | select-object name, cpu
    > 02 get-process | select-object name, cpu
    >
    > the line 02 show only the name and not cpu... whenn i write this manuel in
    > PowerShell is all okay.... as script not work.
    >
    > "Andrey Nepomnyaschih" wrote:
    >

    > > I don't think this has something to do with PowerShell. It is the WMI
    > > provider which can't find the information inside SMBIOS.
    > >
    > > Most likely the $databaseserver server simply doesn't have this
    > > information stored.
    > >
    > > BiswangerG пишет:

    > > > Hello,
    > > >
    > > > i have the PowerShell V2 (CTP) and have createt a ps1 script with more
    > > > Select-Object commands. The first command with Select-Object is Okay, the
    > > > secend Command with Select-Object works not correkt.
    > > >
    > > > z.B. from script:
    > > >
    > > > Get-WmiObject Win32_ComputerSystem -computername $applikationserver |
    > > > Select-Object Name, Manufacturer, model
    > > > Get-WmiObject Win32_ComputerSystem -computername $databaseserver |
    > > > Select-Object Name, Manufacturer, model
    > > >
    > > > the PowerShell Shows only from first Name, Manufacturer, model... with the
    > > > secend shows name without manufacturerer, model...
    > > >
    > > > what is the problem here?
    > > >
    > > >
    > > >
    > > >
    > > >
    > >

      My System SpecsSystem Spec

  7. #7


    Shay Levi Guest

    Re: Select-Object in PS1 Script Bug?!

    Both runs fine on my machine (CTP) either interactively or manually in PowerShell.
    Just a wild guess, could it be a display formating issue?

    get-process | select-object name, cpu | format-table -auto



    -----
    Shay Levi
    $cript Fanatic
    http://scriptolog.blogspot.com
    Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic



    > No, this was a example...
    >
    > this the self problem as script:
    >
    > 01 get-process | select-object name, cpu
    > 02 get-process | select-object name, cpu
    > the line 02 show only the name and not cpu... whenn i write this
    > manuel in PowerShell is all okay.... as script not work.
    >
    > "Andrey Nepomnyaschih" wrote:
    >

    >> I don't think this has something to do with PowerShell. It is the WMI
    >> provider which can't find the information inside SMBIOS.
    >>
    >> Most likely the $databaseserver server simply doesn't have this
    >> information stored.
    >>
    >> BiswangerG ?????:
    >>

    >>> Hello,
    >>>
    >>> i have the PowerShell V2 (CTP) and have createt a ps1 script with
    >>> more Select-Object commands. The first command with Select-Object is
    >>> Okay, the secend Command with Select-Object works not correkt.
    >>>
    >>> z.B. from script:
    >>>
    >>> Get-WmiObject Win32_ComputerSystem -computername $applikationserver
    >>> | Select-Object Name, Manufacturer, model Get-WmiObject
    >>> Win32_ComputerSystem -computername $databaseserver | Select-Object
    >>> Name, Manufacturer, model
    >>>
    >>> the PowerShell Shows only from first Name, Manufacturer, model...
    >>> with the secend shows name without manufacturerer, model...
    >>>
    >>> what is the problem here?
    >>>


      My System SpecsSystem Spec

  8. #8


    Shay Levi Guest

    Re: Select-Object in PS1 Script Bug?!

    Hmm..

    When I put this in a script the second command doesn't show the length:
    get-process | select-object cpu, name
    dir | Select-Object name, length

    A script with only:

    dir | Select-Object name, length

    returns both name and length properties.Odd! Checking...



    -----
    Shay Levi
    $cript Fanatic
    http://scriptolog.blogspot.com
    Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic



    > this is a better example...
    >
    > this as script not working correct:
    >
    > get-process | select-object cpu, name
    > dir | Select-Object name, length
    > "BiswangerG" wrote:
    >

    >> No, this was a example...
    >>
    >> this the self problem as script:
    >>
    >> 01 get-process | select-object name, cpu
    >> 02 get-process | select-object name, cpu
    >> the line 02 show only the name and not cpu... whenn i write this
    >> manuel in PowerShell is all okay.... as script not work.
    >>
    >> "Andrey Nepomnyaschih" wrote:
    >>

    >>> I don't think this has something to do with PowerShell. It is the
    >>> WMI provider which can't find the information inside SMBIOS.
    >>>
    >>> Most likely the $databaseserver server simply doesn't have this
    >>> information stored.
    >>>
    >>> BiswangerG ?????:
    >>>
    >>>> Hello,
    >>>>
    >>>> i have the PowerShell V2 (CTP) and have createt a ps1 script with
    >>>> more Select-Object commands. The first command with Select-Object
    >>>> is Okay, the secend Command with Select-Object works not correkt.
    >>>>
    >>>> z.B. from script:
    >>>>
    >>>> Get-WmiObject Win32_ComputerSystem -computername $applikationserver
    >>>> | Select-Object Name, Manufacturer, model Get-WmiObject
    >>>> Win32_ComputerSystem -computername $databaseserver | Select-Object
    >>>> Name, Manufacturer, model
    >>>>
    >>>> the PowerShell Shows only from first Name, Manufacturer, model...
    >>>> with the secend shows name without manufacturerer, model...
    >>>>
    >>>> what is the problem here?
    >>>>


      My System SpecsSystem Spec

  9. #9


    BiswangerG Guest

    Re: Select-Object in PS1 Script Bug?!

    Perfekt! This Works!

    Thank you

    Example:
    get-process | select-object cpu, name | format-table -auto
    dir | Select-Object name, length




    "Shay Levi" wrote:

    > Both runs fine on my machine (CTP) either interactively or manually in PowerShell.
    > Just a wild guess, could it be a display formating issue?
    >
    > get-process | select-object name, cpu | format-table -auto
    >
    >
    >
    > -----
    > Shay Levi
    > $cript Fanatic
    > http://scriptolog.blogspot.com
    > Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic
    >
    >
    >

    > > No, this was a example...
    > >
    > > this the self problem as script:
    > >
    > > 01 get-process | select-object name, cpu
    > > 02 get-process | select-object name, cpu
    > > the line 02 show only the name and not cpu... whenn i write this
    > > manuel in PowerShell is all okay.... as script not work.
    > >
    > > "Andrey Nepomnyaschih" wrote:
    > >

    > >> I don't think this has something to do with PowerShell. It is the WMI
    > >> provider which can't find the information inside SMBIOS.
    > >>
    > >> Most likely the $databaseserver server simply doesn't have this
    > >> information stored.
    > >>
    > >> BiswangerG ?????:
    > >>
    > >>> Hello,
    > >>>
    > >>> i have the PowerShell V2 (CTP) and have createt a ps1 script with
    > >>> more Select-Object commands. The first command with Select-Object is
    > >>> Okay, the secend Command with Select-Object works not correkt.
    > >>>
    > >>> z.B. from script:
    > >>>
    > >>> Get-WmiObject Win32_ComputerSystem -computername $applikationserver
    > >>> | Select-Object Name, Manufacturer, model Get-WmiObject
    > >>> Win32_ComputerSystem -computername $databaseserver | Select-Object
    > >>> Name, Manufacturer, model
    > >>>
    > >>> the PowerShell Shows only from first Name, Manufacturer, model...
    > >>> with the secend shows name without manufacturerer, model...
    > >>>
    > >>> what is the problem here?
    > >>>
    >
    >
    >

      My System SpecsSystem Spec

  10. #10


    Shay Levi Guest

    Re: Select-Object in PS1 Script Bug?!

    Can one confirm this? when the sample script run I get an error:

    ### test.ps1 ###
    get-process | select-object cpu, name
    dir | Select-Object name, length | format-table -auto
    ############


    out-lineoutput : Object of type "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData"
    is not legal or not in
    the correct sequence. This is likely caused by a user-specified "format-table"
    command which is conflicting with the d
    fault formatting.


    The first command runs, but the second produces an error.

    The script runs successfuly as long as it contains only the second command.

    -----
    Shay Levi
    $cript Fanatic
    http://scriptolog.blogspot.com
    Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic



    > this is a better example...
    >
    > this as script not working correct:
    >
    > get-process | select-object cpu, name
    > dir | Select-Object name, length
    > "BiswangerG" wrote:
    >

    >> No, this was a example...
    >>
    >> this the self problem as script:
    >>
    >> 01 get-process | select-object name, cpu
    >> 02 get-process | select-object name, cpu
    >> the line 02 show only the name and not cpu... whenn i write this
    >> manuel in PowerShell is all okay.... as script not work.
    >>
    >> "Andrey Nepomnyaschih" wrote:
    >>

    >>> I don't think this has something to do with PowerShell. It is the
    >>> WMI provider which can't find the information inside SMBIOS.
    >>>
    >>> Most likely the $databaseserver server simply doesn't have this
    >>> information stored.
    >>>
    >>> BiswangerG ?????:
    >>>
    >>>> Hello,
    >>>>
    >>>> i have the PowerShell V2 (CTP) and have createt a ps1 script with
    >>>> more Select-Object commands. The first command with Select-Object
    >>>> is Okay, the secend Command with Select-Object works not correkt.
    >>>>
    >>>> z.B. from script:
    >>>>
    >>>> Get-WmiObject Win32_ComputerSystem -computername $applikationserver
    >>>> | Select-Object Name, Manufacturer, model Get-WmiObject
    >>>> Win32_ComputerSystem -computername $databaseserver | Select-Object
    >>>> Name, Manufacturer, model
    >>>>
    >>>> the PowerShell Shows only from first Name, Manufacturer, model...
    >>>> with the secend shows name without manufacturerer, model...
    >>>>
    >>>> what is the problem here?
    >>>>


      My System SpecsSystem Spec

Page 1 of 2 12 LastLast
Select-Object in PS1 Script Bug?! problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Select-Object * Larry__Weiss PowerShell 13 10 Feb 2010
select-object bug? Shay Levi PowerShell 9 08 Apr 2008
Unable to Select-Object Tom Moreau PowerShell 20 24 Jan 2008
Select Multi Object in (my) computer Mohammad Reza Farahy Vista General 3 15 Feb 2007
Select object as klumsy@xtra.co.nz PowerShell 4 09 Sep 2006