⚑ PowerShellπŸͺŸ WindowsBeginner

PowerShell Script to Generate a Windows System Inventory

This PowerShell script generates a complete Windows system inventory, including hardware details, OS version, BIOS information, and uptime. The output is automatically written to a timestamped TXT file in C:\Scripts, making it ideal for IT support, MSP workflows, and asset documentation.

36views

Introduction

Windows administrators frequently need a fast and reliable way to collect system information without relying on third-party tools. This Anavem PowerShell script provides a clean, read-only system inventory that can be executed locally, via Intune, or through RMM platforms.

What the Script Collects

  • Computer name and manufacturer
  • Hardware model
  • Windows edition, version, and build
  • BIOS version and serial number
  • CPU model
  • Installed RAM (GB)
  • System uptime

Output Location

The script automatically creates the following directory if it does not exist:

C:\Scripts

A timestamped TXT file is generated on each execution.

How to Run the Script

Method 1 - Manual execution

powershell -ExecutionPolicy Bypass -File .\Anavem-SystemInventory.ps1

Method 2 - Intune / RMM

Use the script as a detection or reporting task. No admin privileges required.

Script Code

<# 
================================================================================
 Anavem.com - PowerShell Script
================================================================================
 Script Name : Anavem-SystemInventory.ps1
 Description : Collects Windows hardware and OS inventory and writes to TXT file
 Author      : Anavem.com
 Version     : 1.1.1
 Website     : https://www.anavem.com

 Use Case    :
 - System inventory
 - IT support diagnostics
 - Asset documentation
 - Intune / RMM reporting

 Run as Admin: No
================================================================================
#>

# Ensure output directory exists
$OutputDir = "C:\Scripts"
if (-not (Test-Path $OutputDir)) {
    New-Item -Path $OutputDir -ItemType Directory -Force | Out-Null
}

# File name with timestamp
$Timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
$OutputFile = "$OutputDir\Anavem-SystemInventory_$Timestamp.txt"

# Collect system information
$cs   = Get-CimInstance Win32_ComputerSystem
$os   = Get-CimInstance Win32_OperatingSystem
$cpu  = Get-CimInstance Win32_Processor | Select-Object -First 1
$bios = Get-CimInstance Win32_BIOS

# Build output
$Inventory = @"
Anavem.com : Windows System Inventory
Script   : Anavem-SystemInventory.ps1
Version  : 1.1.0
Generated: $(Get-Date)
------------------------------------------------------------

Computer Name : $env:COMPUTERNAME
Manufacturer  : $($cs.Manufacturer)
Model         : $($cs.Model)

Operating System : $($os.Caption)
OS Version       : $($os.Version)
OS Build         : $($os.BuildNumber)

BIOS Version : $($bios.SMBIOSBIOSVersion)
Serial No.   : $($bios.SerialNumber)

CPU  : $($cpu.Name)
RAM  : $([math]::Round($cs.TotalPhysicalMemory / 1GB, 2)) GB

Uptime : $((Get-Date) - $os.LastBootUpTime)

------------------------------------------------------------
Generated by Anavem.com
"@

# Write to file
$Inventory | Out-File -FilePath $OutputFile -Encoding UTF8

# Optional console confirmation (safe if run manually)
Write-Host "Inventory saved to $OutputFile"

Security Notes

This script performs read-only CIM queries and does not modify the system, registry, or network configuration. It is safe to run in production environments.

Source Code

Comments

Want to join the discussion?

Create an account to unlock exclusive member content, save your favorite articles, and join our community of IT professionals.

Sign in