JustPaste
HomeCategoriesAboutDonateContactTerms of UsePrivacy Policy
JustPaste

Free online notepad — write and share instantly

Navigate

  • Home
  • Timeline
  • Categories

Info

  • About
  • Donate
  • Contact

Legal

  • Terms of Use
  • Privacy Policy

© 2026 JustPaste.app. All rights reserved.

Made with ♥ by JustPaste

Untitled Page | JustPaste.app
4 months ago73 views
$loggedInUser = (Get-CimInstance Win32_ComputerSystem).UserName
$username = $loggedInUser.Split("\")[-1]
$OutputFile = "C:\Users\$username\Downloads\PC_Specs_Report.csv"

# Create array
$results = @()

# Function to decode Windows Product Key
function Get-WindowsProductKey {
    $keyPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
    $digitalProductId = (Get-ItemProperty -Path $keyPath -Name DigitalProductId).DigitalProductId

    $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, "-")
}

# 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"
}

# Hostname
$hostname = $env:COMPUTERNAME

# Brand + Model
$computer = Get-WmiObject -Class Win32_ComputerSystem
$brand  = $computer.Manufacturer
$model  = $computer.Model

# Serial Number
$serial = (Get-WmiObject -Class Win32_BIOS).SerialNumber

# CPU
$cpu = (Get-WmiObject -Class Win32_Processor).Name

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

# OS Version
$os = (Get-WmiObject -Class Win32_OperatingSystem).Caption

# Storage (GB)
$disk = Get-WmiObject Win32_LogicalDisk -Filter "DriveType=3"
$storageTotal = [math]::Round(($disk.Size | Measure-Object -Sum).Sum / 1GB, 2)

# Corporate Email (UPN)
$corporateEmail = Get-PrimaryUserUPN

# 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
}

# Export to CSV
$results | Export-Csv -Path $OutputFile -NoTypeInformation -Encoding UTF8

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

⚠️Content was pasted as plain text and auto-formatted as a code block. Use the Code Block button in the editor for proper formatting.

← Back to timeline