Skip to content

How to Export a Windows Server Inventory with PowerShell Print

  • 0

Applies to: Windows Server 2019, Windows Server 2022, and Windows Server 2025.

A repeatable inventory captures operating system, hardware, installed roles, uptime, and network data for auditing and migration planning.

Prerequisites

  • PowerShell remoting is enabled to the approved target list.
  • The operator can query CIM and installed-feature data.
  • The export directory is access-controlled because inventory can contain sensitive infrastructure details.

Step-by-step procedure

  1. Create a reviewed list of server FQDNs.
  2. Run the inventory script from a management host.
  3. Inspect connection errors separately instead of treating missing servers as valid empty records.
  4. Export the results to CSV and protect the file with appropriate NTFS permissions.
  5. Store a dated copy in the configuration-management repository.

PowerShell commands

$servers = Get-Content .\servers.txt
$inventory = Invoke-Command -ComputerName $servers -ScriptBlock {
  $os = Get-CimInstance Win32_OperatingSystem
  $cs = Get-CimInstance Win32_ComputerSystem
  [pscustomobject]@{ ComputerName=$env:COMPUTERNAME; OS=$os.Caption; Build=$os.BuildNumber; MemoryGB=[math]::Round($cs.TotalPhysicalMemory/1GB,2); LastBoot=$os.LastBootUpTime }
}
$inventory | Export-Csv .\windows-server-inventory.csv -NoTypeInformation -Encoding UTF8

Verification

Open the CSV, compare the number of unique computer names to the source list, and spot-check operating system build, memory, and uptime values.

Rollback

Delete superseded exports according to the retention policy. The commands are read-only and make no server configuration changes.

Operational and security notes

  • Do not publish internal hostnames or IP addresses.
  • Sign production scripts and log who generated each report.
  • Use scheduled inventories only with a dedicated least-privilege account.

Related resources

For managed Canadian VPS and RDS infrastructure, visit networkmanager.info. See also the official Microsoft Server Manager documentation.


Was this answer helpful?

« Back