Create buildinfo.ps1

This commit is contained in:
Alexander 2024-09-20 08:42:10 -04:00 committed by GitHub
parent 579e8d849b
commit 0587342aaa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

32
assets/buildinfo.ps1 Normal file
View File

@ -0,0 +1,32 @@
# Author: Alexander B.
# This PowerShell script collects information about computer hardware and saves it in a text file.
$System = Get-CimInstance CIM_ComputerSystem
$OS = Get-CimInstance CIM_OperatingSystem
$CPU = Get-CimInstance CIM_Processor
$Storage = Get-CimInstance Win32_LogicalDisk -Filter "DeviceID = 'C:'"
$InfoFile = "pcbuildinfo.txt"
Write-Host "PC Hardware Information"
# Write computer configuration to a text file
"PC Hardware Information" > $InfoFile
" " >> $InfoFile
"This is " + $System.Model + ", and was manufactured by " + $System.Manufacturer >> $InfoFile
"The name of this computer is " + $System.Name + "." >> $InfoFile
"The operating system installed on this computer is " + $OS.caption >> $InfoFile
" " >> $InfoFile
"The CPU, RAM and free storage space are as follows: " >> $InfoFile
" " >> $InfoFile
"CPU: " +$CPU.Name >> $InfoFile
"RAM: " + "{0:N2}" -f ($System.TotalPhysicalMemory/1GB) + " GB" >> $InfoFile
"HDD Capacity: " + "{0:N2}" -f ($Storage.Size/1GB) + " GB" >> $InfoFile
# Print hardware summary on a screen
Write-Host "Model: " $System.Model
Write-Host "Computer: " $System.Name
Write-Host "OS: " $OS.Caption
Write-Host "CPU: " $CPU.Name
#tree /f > directory.txt
# > pcbuildinfo.txt