title: How to convert a $size variable from bytes into GB in Powershell?
body: <p>In Powershell, I would like to convert $size variable from bytes into GB gigabytes. What is the best way to do it? 
  So far I have the following script:</p>
  
  <pre><code>$dir = "C:\Users\student"
  $count = @{}
  $size = @{}
  $hostname = @{}
  gci $dir -recurse |%{
  [int]$count[$_.extension] += 1
  [int64]$size[$_.extension] += $_.length
  }
  $results = @()
  $count.keys | sort |% {
  $result = ""|select extension,count,size,hostname
  $result.extension = $_
  $result.count = $count[$_]
  $result.size = $size[$_]
  $result.hostname = $(get-content env:computername)
  $results += $result
  }
  $results | ft -auto
  $results | sort-object -property size -Descending | select-object -first 30| export-csv c:\"$env:computername-$(get-date -f dd-MM-yyyy-HH-mm)".csv
  </code></pre>