How to format hashtable like Naumber+unit: 5 GB
Get-NetAdapterStatistics| Select-Object Name, @{Name="RE"; Expression={ [System.Math]::Ceiling($_.ReceivedBytes/1GB)}}
How to format hashtable like Naumber+unit: 5 GB
Get-NetAdapterStatistics| Select-Object Name, @{Name="RE"; Expression={ [System.Math]::Ceiling($_.ReceivedBytes/1GB)}}
I didn’t get what you mean. Could you elaborate a little more detailed? Or could you show one or two examples?
I want the following:
Name RE Unit
Ethernet 0 GB
Npcap Loopback Adapter 0 GB
Ethernet 2 97 GB
NordLynx 0 GB
Helyi kapcsolat 2 0 GB
Ethernet 4 37 GB
or:
Name RE
Ethernet 0 GB
Npcap Loopback Adapter 0 GB
Ethernet 2 97 GB
NordLynx 0 GB
Helyi kapcsolat 2 0 GB
Ethernet 4 37 GB
If you just want to output the unit of measurement along with size you can simply add it as string like this:
Get-NetAdapterStatistics | Select-Object Name, @{Name = 'RE';Expression={[System.Math]::Ceiling($_.ReceivedBytes/1GB).ToString() + ' GB'}}
Alternatively you could use the format operator “-f”.
Here are some links to read more about:
Have you tried my code suggestion? Or is there something wrong with it?
This seems to work as well:
Get-NetAdapterStatistics| Select-Object Name, @{Name=“RE”; Expression={[System.Math]::Ceiling($_.ReceivedBytes/1GB)}}, @{Name=‘Unit’; Expression={‘GB’}}