Jake
Jake

Reputation: 183

How do I convert bytes into mb?

In my piped command I want the bytes to be displayed as megabytes. My command queries a list of computers and returns their physical memory.

How do I do the conversion and where do I add it?

$comp = Get-Content c:\users\jasonbe\computerlist2.txt
Get-WmiObject -Class Win32_ComputerSystem -computer $comp | select Name, Totalphysicalmemory |`Export-Csv c:\users\jasonbe\Physical_Mem.csv`

Upvotes: 0

Views: 3984

Answers (1)

mjolinor
mjolinor

Reputation: 68273

 $comp = Get-Content c:\users\jasonbe\computerlist2.txt
 Get-WmiObject -Class Win32_ComputerSystem -computer $comp |
  select Name, @{label="Totalphysicalmemory";expression={[int]($_.totalphysicalmemory/1mb)}}|
  `Export-Csv c:\users\jasonbe\Physical_Mem.csv`

Upvotes: 2

Related Questions