Skip to main content
JustPaste
HomeAboutDonateContactTerms of UsePrivacy Policy

© 2026 Just Paste. All rights reserved.

Made with ❤️ by TakiDev

Untitled Page | JustPaste.app
Publish 7 days ago33 views

# Get logged-in user

$loggedInUser = (Get-CimInstance Win32_ComputerSystem).UserName

$username = $loggedInUser.Split("\")[-1]

# Output file

$OutputFile = "C:\Users\$username\Downloads\PC_Specs_Report.csv"

# Results array

$results = @()

# ------------------------------------------------------------

# Function: Decode Windows Product Key

# ------------------------------------------------------------

function Get-WindowsProductKey {

try {

$keyPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion"

$digitalProductId = (Get-ItemProperty -Path $keyPath -Name DigitalProductId).DigitalProductId

if (-not $digitalProductId) {

return "Not Available"

}

$chars = "BCDFGHJKMPQRTVWXY2346789"

$hexPid = $digitalProductId[52..67]

$result = ""

for ($i = 24; $i -ge 0; $i--) {

$current = 0

for ($j = 14; $j -ge 0; $j--) {

$current = ($current * 256) -bxor $hexPid[$j]

$hexPid[$j] = [math]::Floor($current / 24)

$current = $current % 24

}

$result = $chars[$current] + $result

}

return $result.Insert(5,"-").Insert(11,"-").Insert(17,"-").Insert(23,"-")

}

catch {

return "Not Available"

}

}

# ------------------------------------------------------------

# Function: Get Primary User UPN (Corporate Email)

# ------------------------------------------------------------

function Get-PrimaryUserUPN {

$path = "HKLM:\SOFTWARE\Microsoft\Enrollments"

$enrollments = Get-ChildItem $path -ErrorAction SilentlyContinue

foreach ($item in $enrollments) {

$upn = (Get-ItemProperty -Path $item.PSPath -ErrorAction SilentlyContinue).UPN

if ($upn) { return $upn }

}

return "Not Available"

}

# ------------------------------------------------------------

# Collect System Info

# ------------------------------------------------------------

# Hostname

$hostname = $env:COMPUTERNAME

# Computer system

$computer = Get-CimInstance Win32_ComputerSystem

$brand = $computer.Manufacturer

$model = $computer.Model

# Serial number

$serial = (Get-CimInstance Win32_BIOS).SerialNumber

# CPU

$cpu = (Get-CimInstance Win32_Processor).Name

# RAM (GB)

$ram = [math]::Round($computer.TotalPhysicalMemory / 1GB, 2)

# OS

$os = (Get-CimInstance Win32_OperatingSystem).Caption

# Storage (GB)

$disk = Get-CimInstance Win32_LogicalDisk -Filter "DriveType=3"

$storageTotal = [math]::Round(($disk.Size | Measure-Object -Sum).Sum / 1GB, 2)

# Corporate Email

$corporateEmail = Get-PrimaryUserUPN

# Windows Product Key

$productKey = Get-WindowsProductKey

# ------------------------------------------------------------

# Add to results (ORDER MATTERS)

# ------------------------------------------------------------

$results += [PSCustomObject]@{

CorporateEmail = $corporateEmail

Hostname = $hostname

Brand = $brand

Model = $model

SerialNumber = $serial

CPU = $cpu

OS_Windows = $os

Storage_GB = $storageTotal

RAM_GB = $ram

ProductKey = $productKey

}

# ------------------------------------------------------------

# Export CSV

# ------------------------------------------------------------

$results | Export-Csv -Path $OutputFile -NoTypeInformation -Encoding UTF8

Write-Host "PC Spec report saved to: $OutputFile"