Solved Collecting System Information using PowerShell Script


FreeBooter

Well-known member
Pro User
VIP
Local time
1:40 AM
Posts
3,923
OS
Windows 11
Using this PowerShell script, detailed PC system information can be displayed.

2025-01-28_10-10-53.webp

To run PowerShell scripts, it may be necessary to change the PowerShell execution policy.



Powershell:
# Collecting System Information using PowerShell
# Coded by FreeBooter

Clear-Host
Write-Host ""

# Define a function to get startup programs
function Get-StartupPrograms
{
    $startupPrograms = @()
   
    # Get startup items from the registry
    $registryPaths = @(
        "HKLM:\Software\Microsoft\Windows\CurrentVersion\Run",
        "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run"
    )
   
    foreach ($path in $registryPaths)
    {
        $items = Get-ItemProperty -Path $path
        foreach ($item in $items.PSObject.Properties)
        {
            if ($item.Name -ne "PSPath" -and $item.Name -ne "PSParentPath" -and $item.Name -ne "PSChildName" -and $item.Name -ne "PSDrive" -and $item.Name -ne "PSProvider")
            {
                $startupPrograms += [PSCustomObject]@{
                    Name   = $item.Name
                    Value  = $item.Value
                    Source = $path
                }
            }
        }
    }
   
    # Get startup items from the startup folder
    $startupFolderPaths = @(
        "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup",
        "$env:PROGRAMDATA\Microsoft\Windows\Start Menu\Programs\Startup"
    )
   
    foreach ($folderPath in $startupFolderPaths)
    {
        $items = Get-ChildItem -Path $folderPath -Filter *.lnk
        foreach ($item in $items)
        {
            $startupPrograms += [PSCustomObject]@{
                Name   = $item.Name
                Value  = $item.FullName
                Source = $folderPath
            }
        }
    }
   
    return $startupPrograms
}

# Define a function to get GPU information
function Get-GPUInfo
{
    Get-WmiObject -Namespace "root\cimv2" -Class "Win32_VideoController" |
    Select-Object -Property Name, AdapterRAM, DriverVersion, VideoProcessor, Caption
}


$Serial = Get-WmiObject -Class Win32_BIOS | Select-Object -Property SerialNumber


# Get operating system information
$os = Get-WmiObject -Class Win32_OperatingSystem

# Get computer system information
$computerSystem = Get-WmiObject -Class Win32_ComputerSystem

# Get processor information
$processor = Get-WmiObject -Class Win32_Processor

# Get memory information
$memory = Get-WmiObject -Class Win32_PhysicalMemory

# Get BIOS information
$bios = Get-WmiObject -Class Win32_BIOS

# Get disk drive information
$diskDrives = Get-WmiObject -Class Win32_DiskDrive

# Get network adapter information
$networkAdapters = Get-WmiObject -Class Win32_NetworkAdapterConfiguration | Where-Object { $_.IPEnabled -eq $true }

# Collect installed software information
$installedSoftware = Get-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*" |
    Select-Object DisplayName, DisplayVersion, Publisher, InstallDate

# Display the information
Write-Host "System Information:" -ForegroundColor Green
Write-Host ""
Write-Host "Operating System:" $os.Caption
Write-Host ""
Write-Host "Version:" $os.Version
Write-Host ""
Write-Host "Computer Name:" $computerSystem.Name
Write-Host ""
Write-Host "Manufacturer:" $computerSystem.Manufacturer
Write-Host ""
Write-Host "Model:" $computerSystem.Model
Write-Host ""
Write-Host "PC Serial Number: " $Serial.SerialNumber
Write-Host ""
Write-Host "Processor:" $processor.Name
Write-Host ""
Write-Host "BIOS Version:" $bios.SMBIOSBIOSVersion
Write-Host ""
Write-Host "Total Physical Memory:" ($computerSystem.TotalPhysicalMemory / 1GB).ToString("0.00") + " GB"
Write-Host ""
Write-Host "Disk Drives:" -ForegroundColor Green


foreach ($drive in $diskDrives)
{
   
    Write-Host "`tDrive Model:" $drive.Model
    Write-Host "`tSize:" ($drive.Size / 1GB).ToString("0.00") + " GB"
}
Write-Host ""
Write-Host "GPU information:" -ForegroundColor Green

# Call the function and output the information
Get-GPUInfo | Format-Table -AutoSize


Write-Host "Network Adapters:" -ForegroundColor Green
foreach ($adapter in $networkAdapters)
{
    Write-Host "`tAdapter:" $adapter.Description
    Write-Host "`tMAC Address:" $adapter.MACAddress
    Write-Host "`tIP Address:" ($adapter.IPAddress -join ", ")
}
Write-Host ""
Write-Host "Installed Software:" -ForegroundColor Green
foreach ($software in $installedSoftware)
{
    Write-Host ""
    Write-Host "`tName:" $software.DisplayName -ForegroundColor Yellow
    Write-Host "`tVersion:" $software.DisplayVersion
    Write-Host "`tPublisher:" $software.Publisher
    Write-Host "`tInstall Date:" $software.InstallDate
}

Write-Host ""
Write-Host "All the programs that run at startup:" -ForegroundColor Green

# Call the function and output the information
Get-StartupPrograms | Format-Table -AutoSize
 

Attachments

Last edited:

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP Pavilion
    CPU
    AMD Ryzen 7 5700G
    Motherboard
    Erica6
    Memory
    Micron Technology DDR4-3200 16GB
    Graphics Card(s)
    NVIDIA GeForce RTX 3060
    Sound Card
    Realtek ALC671
    Monitor(s) Displays
    Samsung SyncMaster U28E590
    Screen Resolution
    3840 x 2160
    Hard Drives
    SAMSUNG MZVLQ1T0HALB-000H1
I wrote this Batch a few years ago for quick info on client PCs. Majority runs via wmic, but feel free to snag whatever you want to add to your script.

Code:
@ECHO OFF
MODE CON COLS=110
ECHO Computer Make/Model:
wmic computersystem get manufacturer,model
ECHO Computer Name:
wmic computersystem get name
ECHO.
ECHO Computer Processor (CPU):
wmic cpu get name,numberofcores
ECHO Disk Information (SSD/HDD):
PowerShell "Get-PhysicalDisk | FT -auto"
ECHO Disk Connection Type (SSD/HDD):
wmic /namespace:\\root\microsoft\windows\storage path msft_disk get BusType
ECHO Serial Number:
wmic csproduct get identifyingnumber
ECHO BIOS:
wmic bios get manufacturer,smbiosbiosversion
ECHO Computer Memory (RAM):
wmic memorychip where "devicelocator != 'SYSTEM ROM'" get capacity,devicelocator,manufacturer,partnumber,memorytype,speed
ECHO Opeating System:
wmic os get caption,osarchitecture,buildnumber
ECHO Windows Product Key:
wmic path softwarelicensingservice get OA3xOriginalProductKey
ECHO Logical Drives (Partitions):
wmic logicaldisk get description,deviceid,freespace,size,volumename
ECHO Physical Network Interface(s) (NIC):
wmic NIC where "physicaladapter=TRUE" get MACAddress,ProductName | findstr /v /C:"Virtual"
ECHO IP Address:
wmic NICCONFIG WHERE IPEnabled=true GET IPAddress
ECHO Currently Active Network Interfaces (NIC):
wmic nicconfig where ipenabled="TRUE" get description,macaddress,ipaddress,dhcpleaseobtained
PAUSE

I pulled these lines out, as if you want to use them, you’ll need uptime.exe and dumpedid.exe attached (rename .txt to .exe)

Code:
ECHO Computer Uptime:
systeminfo | findstr "Time:"
uptime.exe
ECHO Monitor Information:
.\DumpEDID.exe
 

Attachments

My Computer

System One

  • OS
    Windows 11 Pro
Thank you, @dacrone i have a batch script that displays uptime i want to keep my posted script completely PowerShell.
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP Pavilion
    CPU
    AMD Ryzen 7 5700G
    Motherboard
    Erica6
    Memory
    Micron Technology DDR4-3200 16GB
    Graphics Card(s)
    NVIDIA GeForce RTX 3060
    Sound Card
    Realtek ALC671
    Monitor(s) Displays
    Samsung SyncMaster U28E590
    Screen Resolution
    3840 x 2160
    Hard Drives
    SAMSUNG MZVLQ1T0HALB-000H1

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP Pavilion
    CPU
    AMD Ryzen 7 5700G
    Motherboard
    Erica6
    Memory
    Micron Technology DDR4-3200 16GB
    Graphics Card(s)
    NVIDIA GeForce RTX 3060
    Sound Card
    Realtek ALC671
    Monitor(s) Displays
    Samsung SyncMaster U28E590
    Screen Resolution
    3840 x 2160
    Hard Drives
    SAMSUNG MZVLQ1T0HALB-000H1
Thank you, @dacrone i have a batch script that displays uptime i want to keep my posted script completely PowerShell.
All of it can be added into your powershell script if desired. Just have to slightly edit the commands (to CIM)

See @garlin post #9

and

 

My Computer

System One

  • OS
    Windows 11 Pro
Now also displays uptime of PC.

Powershell:
# Collecting System Information using PowerShell
# Coded by FreeBooter

Clear-Host
Write-Host "System Information:" -ForegroundColor Green
Write-Host ""

# Define a function to get startup programs
function Get-StartupPrograms
{
    $startupPrograms = @()
    
    # Get startup items from the registry
    $registryPaths = @(
        "HKLM:\Software\Microsoft\Windows\CurrentVersion\Run",
        "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run"
    )
    
    foreach ($path in $registryPaths)
    {
        $items = Get-ItemProperty -Path $path
        foreach ($item in $items.PSObject.Properties)
        {
            if ($item.Name -ne "PSPath" -and $item.Name -ne "PSParentPath" -and $item.Name -ne "PSChildName" -and $item.Name -ne "PSDrive" -and $item.Name -ne "PSProvider")
            {
                $startupPrograms += [PSCustomObject]@{
                    Name   = $item.Name
                    Value  = $item.Value
                    Source = $path
                }
            }
        }
    }
    
    # Get startup items from the startup folder
    $startupFolderPaths = @(
        "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup",
        "$env:PROGRAMDATA\Microsoft\Windows\Start Menu\Programs\Startup"
    )
    
    foreach ($folderPath in $startupFolderPaths)
    {
        $items = Get-ChildItem -Path $folderPath -Filter *.lnk
        foreach ($item in $items)
        {
            $startupPrograms += [PSCustomObject]@{
                Name   = $item.Name
                Value  = $item.FullName
                Source = $folderPath
            }
        }
    }
    
    return $startupPrograms
}

# Define a function to get GPU information
function Get-GPUInfo
{
    Get-WmiObject -Namespace "root\cimv2" -Class "Win32_VideoController" |
    Select-Object -Property Name, AdapterRAM, DriverVersion, VideoProcessor, Caption
}

# Retrieve the last boot-up time
$osInfo = Get-WmiObject -Class Win32_OperatingSystem
$lastBootUpTime = $osInfo.ConvertToDateTime($osInfo.LastBootUpTime)

# Calculate the uptime
$uptime = New-TimeSpan -Start $lastBootUpTime -End (Get-Date)

# Display the uptime
Write-Output "System Uptime: $($uptime.Days) days, $($uptime.Hours) hours, $($uptime.Minutes) minutes, $($uptime.Seconds) seconds"




$UpTime = Get-CimInstance -ClassName win32_operatingsystem | Select-Object LastBootUpTime

# Get operating system information
$os = Get-WmiObject -Class Win32_OperatingSystem

# Get computer system information
$computerSystem = Get-WmiObject -Class Win32_ComputerSystem

# Get processor information
$processor = Get-WmiObject -Class Win32_Processor

# Get memory information
$memory = Get-WmiObject -Class Win32_PhysicalMemory

# Get BIOS information
$bios = Get-WmiObject -Class Win32_BIOS



# Get disk drive information
$diskDrives = Get-WmiObject -Class Win32_DiskDrive

# Get network adapter information
$networkAdapters = Get-WmiObject -Class Win32_NetworkAdapterConfiguration | Where-Object { $_.IPEnabled -eq $true }

# Collect installed software information
$installedSoftware = Get-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*" |
    Select-Object DisplayName, DisplayVersion, Publisher, InstallDate

# Display the information

Write-Host ""
Write-Host "Operating System:" $os.Caption
Write-Host ""
Write-Host "Version:" $os.Version
Write-Host ""
Write-Host "Computer Name:" $computerSystem.Name
Write-Host ""
Write-Host "Manufacturer:" $computerSystem.Manufacturer
Write-Host ""
Write-Host "Model:" $computerSystem.Model
Write-Host ""
Write-Host "PC Serial Number: " $Serial.SerialNumber
Write-Host ""
Write-Host "Processor:" $processor.Name
Write-Host ""
Write-Host "BIOS Version:" $bios.SMBIOSBIOSVersion
Write-Host ""
Write-Host "Total Physical Memory:" ($computerSystem.TotalPhysicalMemory / 1GB).ToString("0.00") + " GB"
Write-Host ""
Write-Host "Disk Drives:" -ForegroundColor Green


foreach ($drive in $diskDrives)
{
    
    Write-Host "`tDrive Model:" $drive.Model
    Write-Host "`tSize:" ($drive.Size / 1GB).ToString("0.00") + " GB"
}
Write-Host ""
Write-Host "GPU information:" -ForegroundColor Green

# Call the function and output the information
Get-GPUInfo | Format-Table -AutoSize


Write-Host "Network Adapters:" -ForegroundColor Green
foreach ($adapter in $networkAdapters)
{
    Write-Host "`tAdapter:" $adapter.Description
    Write-Host "`tMAC Address:" $adapter.MACAddress
    Write-Host "`tIP Address:" ($adapter.IPAddress -join ", ")
}
Write-Host ""
Write-Host "Installed Software:" -ForegroundColor Green
foreach ($software in $installedSoftware)
{
    Write-Host ""
    Write-Host "`tName:" $software.DisplayName -ForegroundColor Yellow
    Write-Host "`tVersion:" $software.DisplayVersion
    Write-Host "`tPublisher:" $software.Publisher
    Write-Host "`tInstall Date:" $software.InstallDate
}

Write-Host ""
Write-Host "All the programs that run at startup:" -ForegroundColor Green

# Call the function and output the information
Get-StartupPrograms | Format-Table -AutoSize
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP Pavilion
    CPU
    AMD Ryzen 7 5700G
    Motherboard
    Erica6
    Memory
    Micron Technology DDR4-3200 16GB
    Graphics Card(s)
    NVIDIA GeForce RTX 3060
    Sound Card
    Realtek ALC671
    Monitor(s) Displays
    Samsung SyncMaster U28E590
    Screen Resolution
    3840 x 2160
    Hard Drives
    SAMSUNG MZVLQ1T0HALB-000H1

Latest Support Threads

Back
Top Bottom