01 / INVENTORY AND CONFIGURATION REPORTING · LESSON 01

Build a useful server inventory

Select active servers and turn exported byte counts into useful numeric inventory fields.

12 min · learn at your pace

Start with the systems in scope

An inventory report needs a clear population. This fictional export includes active servers, a retired server, and a workstation. The task asks for active servers only. Use both Kind and State in the filter; neither condition alone defines the requested scope.

Each row has a stable AssetId. Preserve it alongside the readable computer name. Names can change, and two exports may describe the same asset under different labels. We will use the identifier again when joining ownership records.

Give numbers a deliberate type

Import-Csv returns strings. Convert MemoryBytes to [long] before arithmetic so the report carries numeric memory values, not formatted text. A 64-bit integer is large enough for these supplied byte counts.

[long]34359738368 / 1GB

PowerShell's 1GB numeric multiplier is 1,073,741,824 bytes. That is a gibibyte, so the output column is named MemoryGiB. Decimal gigabytes use a different divisor. A unit in the property name helps the next person use the data correctly.

Emit custom objects or a calculated Select-Object property. Keep formatting out of the result pipeline: Format-Table creates display instructions that cannot serve as a reusable inventory.

All required data is supplied. The browser does not query Windows, CIM, SSH, or an asset-management service. The transformation you write here can later sit behind an appropriate collector in your own environment.

Go deeper

Read the official reference.

Try an example.ps1
Import-Csv '/home/user/servers.csv' | Select-Object -First 2 AssetId, Name, MemoryBytes
YOUR TURN

Put it into practice.

Read servers.csv and emit one object for each active server (Kind Server and State Active). Keep AssetId, Name, and OS; add numeric MemoryGiB by dividing MemoryBytes by 1GB. Exclude the retired server and workstation. Order does not matter.

See an explained solution
One way to solve it.ps1
Import-Csv '/home/user/servers.csv' | Where-Object { $_.Kind -eq 'Server' -and $_.State -eq 'Active' } | ForEach-Object { [pscustomobject]@{ AssetId=$_.AssetId; Name=$_.Name; OS=$_.OS; MemoryGiB=[long]$_.MemoryBytes / 1GB } }

The two filters define the report population. Numeric conversion and the GiB divisor produce reusable values of 32, 64, and 8 while preserving each asset identifier.