Windows Vista Forums

format-list and output formatting
  1. #1


    Blake Guest

    format-list and output formatting

    I am using the SCVMM libraries to query VM information.

    get-vm -vmmserver blah.blah.com | sort-object name _ format-list
    -property Name, CPUCount, TotalSize

    Here is my problem - this works great - except TotalSize (the disk
    space) is output in bytes. I'd like to convert this to GB. If I simply
    replace TotalSize with TotalSize\gb, it blows up.

    Thoughts?





    B

      My System SpecsSystem Spec

  2. #2


    Vadims Podans [MVP] Guest

    Re: format-list and output formatting

    try this:
    get-vm -vmmserver blah.blah.com | sort-object name _ format-list -property
    Name, CPUCount, @{l='TotalSize (Gb)';e={($_.totalsize /
    1gb).tostring("F02")}
    --
    WBR, Vadims Podans
    MVP: PowerShell
    PowerShell blog - www.sysadmins.lv

    "Blake" <blake.duffey@xxxxxx> rakstija zinojuma
    "news:e8E4lAn0JHA.1372@xxxxxx"...

    > I am using the SCVMM libraries to query VM information.
    >
    > get-vm -vmmserver blah.blah.com | sort-object name _ format-list -property
    > Name, CPUCount, TotalSize
    >
    > Here is my problem - this works great - except TotalSize (the disk space)
    > is output in bytes. I'd like to convert this to GB. If I simply replace
    > TotalSize with TotalSize\gb, it blows up.
    >
    > Thoughts?
    >
    >
    >
    > B

      My System SpecsSystem Spec

  3. #3


    Blake Guest

    Re: format-list and output formatting

    I think there is a missing brace in that statement...

    I get >> and no returned value

    Vadims Podans [MVP] wrote:

    > try this:
    > get-vm -vmmserver blah.blah.com | sort-object name _ format-list
    > -property Name, CPUCount, @{l='TotalSize (Gb)';e={($_.totalsize /
    > 1gb).tostring("F02")}

      My System SpecsSystem Spec

  4. #4


    Vadims Podans [MVP] Guest

    Re: format-list and output formatting

    yes, I miss one closing brace.
    get-vm -vmmserver blah.blah.com | sort-object name _ format-list -property
    Name, CPUCount, @{n='TotalSize (Gb)';e={($_.totalsize /
    1gb).tostring("F02")}}
    --
    WBR, Vadims Podans
    MVP: PowerShell
    PowerShell blog - www.sysadmins.lv

    "Blake" <blake.duffey@xxxxxx> rakstija zinojuma
    "news:#hlM5fn0JHA.5032@xxxxxx"...

    > I think there is a missing brace in that statement...
    >
    > I get >> and no returned value
    >
    > Vadims Podans [MVP] wrote:

    >> try this:
    >> get-vm -vmmserver blah.blah.com | sort-object name _
    >> format-list -property Name, CPUCount, @{l='TotalSize
    >> (Gb)';e={($_.totalsize / 1gb).tostring("F02")}

      My System SpecsSystem Spec

  5. #5


    Blake Guest

    Re: format-list and output formatting

    I get the following error:

    Format-List : Illegal key n
    At line:1 char:78
    + get-vm -vmmserver blah.blah.com | sort-object name | format-list <<<<
    -property Name, @{n='TotalSize (G
    b)';e={($_.totalsize / 1gb).tostring("F02")}}

    Vadims Podans [MVP] wrote:

    > yes, I miss one closing brace.
    > get-vm -vmmserver blah.blah.com | sort-object name _ format-list
    > -property Name, CPUCount, @{n='TotalSize (Gb)';e={($_.totalsize /
    > 1gb).tostring("F02")}}

      My System SpecsSystem Spec

  6. #6


    Blake Guest

    Re: format-list and output formatting

    I think I got it - I replaced 'n' with 'l'



    Blake wrote:

    > I get the following error:
    >
    > Format-List : Illegal key n
    > At line:1 char:78
    > + get-vm -vmmserver blah.blah.com | sort-object name | format-list <<<<
    > -property Name, @{n='TotalSize (G
    > b)';e={($_.totalsize / 1gb).tostring("F02")}}
    >
    > Vadims Podans [MVP] wrote:

    >> yes, I miss one closing brace.
    >> get-vm -vmmserver blah.blah.com | sort-object name _ format-list
    >> -property Name, CPUCount, @{n='TotalSize (Gb)';e={($_.totalsize /
    >> 1gb).tostring("F02")}}

      My System SpecsSystem Spec

  7. #7


    Blake Guest

    Re: format-list and output formatting

    Thanks so much for your help!
    Blake

    Blake wrote:

    > I get the following error:
    >
    > Format-List : Illegal key n
    > At line:1 char:78
    > + get-vm -vmmserver blah.blah.com | sort-object name | format-list <<<<
    > -property Name, @{n='TotalSize (G
    > b)';e={($_.totalsize / 1gb).tostring("F02")}}
    >
    > Vadims Podans [MVP] wrote:

    >> yes, I miss one closing brace.
    >> get-vm -vmmserver blah.blah.com | sort-object name _ format-list
    >> -property Name, CPUCount, @{n='TotalSize (Gb)';e={($_.totalsize /
    >> 1gb).tostring("F02")}}

      My System SpecsSystem Spec

  8. #8


    Vadims Podans [MVP] Guest

    Re: format-list and output formatting

    Yep. Looks like, its a time to go sleep.

    good night!
    --
    WBR, Vadims Podans
    MVP: PowerShell
    PowerShell blog - www.sysadmins.lv

    "Blake" <blake.duffey@xxxxxx> rakstija zinojuma
    "news:eYze4rn0JHA.3408@xxxxxx"...

    > I think I got it - I replaced 'n' with 'l'
    >
    >
    >
    > Blake wrote:

    >> I get the following error:
    >>
    >> Format-List : Illegal key n
    >> At line:1 char:78
    >> + get-vm -vmmserver blah.blah.com | sort-object name | format-list
    >> <<<< -property Name, @{n='TotalSize (G
    >> b)';e={($_.totalsize / 1gb).tostring("F02")}}
    >>
    >> Vadims Podans [MVP] wrote:

    >>> yes, I miss one closing brace.
    >>> get-vm -vmmserver blah.blah.com | sort-object name _
    >>> format-list -property Name, CPUCount, @{n='TotalSize
    >>> (Gb)';e={($_.totalsize / 1gb).tostring("F02")}}

      My System SpecsSystem Spec

format-list and output formatting

Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting output Carlos Felipe França da Fonseca PowerShell 2 02 Sep 2009
Formatting output elmerick PowerShell 3 26 Apr 2009
-f format Format-Table Format-List against Select Personne PowerShell 5 25 Nov 2008
formatting AD output Kev T PowerShell 8 01 Feb 2008
get-help output formatting bug klumsy@xtra.co.nz PowerShell 1 11 Nov 2006