How to convert value to mb powershell script

Welcome Forums General PowerShell Q&A How to convert value to mb powershell script

This topic contains 6 replies, has 2 voices, and was last updated by

 
Participant
6 months, 4 weeks ago.

  • Author
    Posts
  • #99136

    Participant
    Points: 0
    Rank: Member

    $h = @{}
    get-wmiobject win32_process | foreach {
    $u = $_.getowner().user;
    if ( $u -ne $null)
    {
    if ( !$h.ContainsKey($u) )
    {
    $h.add( $u, $_.PrivatePageCount);
    }
    else
    {
    $h.item($u) = $h.item($u) + $_.PrivatePageCount;
    }
    }
    }
    $h.GetEnumerator() | sort value -desc

  • #99139

    Participant
    Points: 134
    Helping Hand
    Rank: Participant
    8388608 / 1MB

    or

    16777216 / 1MB
    • #99142

      Participant
      Points: 0
      Rank: Member

      where write that?
      Because i don't know much, thank you

    • #99145

      Participant
      Points: 134
      Helping Hand
      Rank: Participant

      Where do you want the value converted to MB?

    • #99147

      Participant
      Points: 0
      Rank: Member

      with getenumerator because the Value is a property

  • #99148

    Participant
    Points: 134
    Helping Hand
    Rank: Participant

    You could use a Select-Object with a calculated property

    ....  | Select-Object -Property Name,@{Name='Value';Expression={$_.Value / 1MB}}
    • #99150

      Participant
      Points: 0
      Rank: Member

      Thank you. it works 😉
      Great

The topic ‘How to convert value to mb powershell script’ is closed to new replies.