-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPC.ps1
105 lines (79 loc) · 3.13 KB
/
PC.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# PC
# by ImKKingshuk
# Git- https://github.com/ImKKingshuk/WindowsNinja.git
# Copyright © 2024 , @ImKKingshuk | All Rights Reserved.
# GNU General Public License v3.0 or later
function Get-FormattedCimInstance {
param (
[string]$ClassName,
[hashtable]$Properties
)
try {
$cimInstance = Get-CimInstance -ClassName $ClassName
$formattedData = $cimInstance | Select-Object -Property $Properties | Format-Table | Out-String
Write-Output $formattedData.Trim()
} catch {
Write-Host "Error retrieving information from $ClassName: $_"
}
}
function Get-FormattedPhysicalDisk {
try {
$formattedDisks = Get-PhysicalDisk | Select-Object -Property FriendlyName, MediaType, BusType, @{Name = 'Size, GB'; Expression = {[math]::Round($_.Size / 1GB, 2)}} | Format-Table | Out-String
Write-Output $formattedDisks.Trim()
} catch {
Write-Host "Error retrieving Physical Disk information: $_"
}
}
function Get-FormattedVideoControllers {
try {
$integratedGraphics = Get-CimInstance -ClassName CIM_VideoController | Where-Object {$_.AdapterDACType -eq "Internal"}
if ($integratedGraphics) {
$integratedGraphics | Select-Object -Property Caption, @{Name = 'VRAM, GB'; Expression = {[math]::Round($_.AdapterRAM / 1GB)}}
}
$qwMemorySize = (Get-ItemProperty -Path "HKLM:\SYSTEM\ControlSet001\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\0*" -Name HardwareInformation.qwMemorySize -ErrorAction SilentlyContinue)."HardwareInformation.qwMemorySize"
if ($qwMemorySize) {
$dedicatedGraphics = Get-CimInstance -ClassName CIM_VideoController | Where-Object {$_.AdapterDACType -ne "Internal"}
foreach ($VRAM in $qwMemorySize) {
$dedicatedGraphics | ForEach-Object {
[PSCustomObject] @{
Model = $_.Caption
"VRAM, GB" = [math]::Round($VRAM / 1GB)
}
}
}
}
} catch {
Write-Host "Error retrieving Video Controllers information: $_"
}
}
Clear-Host
Write-Output "`nBIOS"
Get-FormattedCimInstance -ClassName CIM_BIOSElement -Properties @{
Manufacturer = "Manufacturer"
Version = "Version"
}
Write-Output "`nMotherboard"
Get-FormattedCimInstance -ClassName Win32_BaseBoard -Properties @{
Manufacturer = "Manufacturer"
Product = "Product"
}
Write-Output "`nSerial number"
(Get-CimInstance -ClassName Win32_BIOS).SerialNumber
Write-Output "`nCPU"
Get-FormattedCimInstance -ClassName CIM_Processor -Properties @{
Name = "Name"
Cores = "NumberOfCores"
"L3, MB" = {$_.L3CacheSize / 1024}
Threads = "NumberOfLogicalProcessors"
}
Write-Output "`nRAM"
Get-FormattedCimInstance -ClassName CIM_PhysicalMemory -Properties @{
Manufacturer = "Manufacturer"
PartNumber = "PartNumber"
"Speed, MHz" = "ConfiguredClockSpeed"
"Capacity, GB" = {$_.Capacity / 1GB}
}
Write-Output "`nPhysical disks"
Get-FormattedPhysicalDisk
Write-Output "`nVideo controllers"
Get-FormattedVideoControllers