-
Notifications
You must be signed in to change notification settings - Fork 47
/
Data.psm1
209 lines (169 loc) · 6.05 KB
/
Data.psm1
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
Add-Type -AssemblyName System.Windows.Forms
Function Get-SystemSpecifications()
{
$UserInfo = Get-UserInformation;
$OS = Get-OS;
$Kernel = Get-Kernel;
$Uptime = Get-FormattedUptime;
$Motherboard = Get-Mobo;
$Shell = Get-Shell;
$Resolution = Get-Resolution;
$WM = Get-WM;
$Font = Get-Font;
$CPU = Get-CPU;
$GPU = Get-GPU;
$RAM = Get-RAM;
$Disks = Get-Disks;
[System.Collections.ArrayList] $SystemInfoCollection =
$UserInfo,
$OS,
$Kernel,
$Uptime,
$Motherboard,
$Shell,
$Resolution,
$WM,
$Font,
$CPU,
$GPU,
$RAM;
foreach ($Disk in $Disks)
{
[void]$SystemInfoCollection.Add($Disk);
}
return $SystemInfoCollection;
}
Function Get-LineToTitleMappings()
{
$TitleMappings = @{
0 = "";
1 = "OS: ";
2 = "Kernel Version: ";
3 = "Uptime: ";
4 = "Motherboard: ";
5 = "Shell: ";
6 = "Resolution: ";
7 = "Window Manager: ";
8 = "Font: ";
9 = "CPU: ";
10 = "GPU ";
11 = "RAM: ";
};
return $TitleMappings;
}
Function Get-UserInformation()
{
return (Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object UserName).UserName.Split('\')[1];
}
Function Get-OS()
{
return (Get-CimInstance -Class CIM_OperatingSystem).Caption + ", " + (Get-CimInstance -Class CIM_OperatingSystem).OSArchitecture;
}
Function Get-Kernel()
{
return [System.Environment]::OSVersion.Version;
}
Function Get-FormattedUptime()
{
$Uptime = Get-Uptime
$FormattedUptime = $Uptime.Days.ToString() + "d " + $Uptime.Hours.ToString() + "h " + $Uptime.Minutes.ToString() + "m " + $Uptime.Seconds.ToString() + "s ";
return $FormattedUptime;
}
Function Get-Mobo()
{
$Motherboard = Get-CimInstance Win32_BaseBoard | Select-Object Manufacturer, Product;
return $Motherboard.Manufacturer + " " + $Motherboard.Product;
}
Function Get-Shell()
{
return "PowerShell $($PSVersionTable.PSVersion.ToString())";
}
Function Get-Resolution()
{
$Horizontal = Out-String -InputObject (Get-CimInstance Win32_VideoController).CurrentHorizontalResolution -NoNewline;
$Vertical = Out-String -InputObject (Get-CimInstance Win32_VideoController).CurrentVerticalResolution -NoNewline;
return $Horizontal + " x " + $Vertical;
}
Function Get-WM()
{
return "DWM";
}
# THIS USUALLY WILL OUTPUT INCORRECT RESULTS. STATICALLY SETTING THIS VALUE IS NO BUENO. NEED TO REMOVE BUT WANT TO GET THIS RELEASED FIRST.
Function Get-Font()
{
return "Segoe UI";
}
Function Get-CPU()
{
return (Get-CimInstance -Class CIM_Processor).Name;
}
Function Get-GPU()
{
return (Get-CimInstance -Class Win32_VideoController).Name;
}
Function Get-RAM()
{
$FreeRam = ([math]::Truncate((Get-CIMInstance Win32_OperatingSystem).FreePhysicalMemory / 1MB));
$TotalRam = ([math]::Truncate((Get-CIMInstance Win32_OperatingSystem).TotalVisibleMemorySize / 1MB));
$UsedRam = $TotalRam - $FreeRam;
$FreeRamPercent = ($FreeRam / $TotalRam) * 100;
$FreeRamPercent = "{0:N0}" -f $FreeRamPercent;
$UsedRamPercent = ($UsedRam / $TotalRam) * 100;
$UsedRamPercent = "{0:N0}" -f $UsedRamPercent;
return $UsedRam.ToString() + "GB / " + $TotalRam.ToString() + "GB " + "(" + $UsedRamPercent.ToString() + "%" + ")";
}
Function Get-Disks()
{
$FormattedDisks = New-Object System.Collections.Generic.List[System.Object];
$NumDisks = (Get-CimInstance Win32_LogicalDisk).Count;
if ($NumDisks)
{
for ($i=0; $i -lt ($NumDisks); $i++)
{
$DiskID = (Get-CimInstance Win32_LogicalDisk)[$i].DeviceId;
$FreeDiskSize = (Get-CimInstance Win32_LogicalDisk)[$i].FreeSpace
$FreeDiskSizeGB = $FreeDiskSize / 1073741824;
$FreeDiskSizeGB = "{0:N0}" -f $FreeDiskSizeGB;
$DiskSize = (Get-CimInstance Win32_LogicalDisk)[$i].Size;
$DiskSizeGB = $DiskSize / 1073741824;
$DiskSizeGB = "{0:N0}" -f $DiskSizeGB;
$FreeDiskPercent = ($FreeDiskSizeGB / $DiskSizeGB) * 100;
$FreeDiskPercent = "{0:N0}" -f $FreeDiskPercent;
$UsedDiskSizeGB = $DiskSizeGB - $FreeDiskSizeGB;
$UsedDiskPercent = ($UsedDiskSizeGB / $DiskSizeGB) * 100;
$UsedDiskPercent = "{0:N0}" -f $UsedDiskPercent;
$FormattedDisk = "Disk " + $DiskID.ToString() + " " +
$UsedDiskSizeGB.ToString() + "GB" + " / " + $DiskSizeGB.ToString() + "GB " +
"(" + $UsedDiskPercent.ToString() + "%" + ")";
$FormattedDisks.Add($FormattedDisk);
}
}
else
{
$DiskID = (Get-CimInstance Win32_LogicalDisk).DeviceId;
$FreeDiskSize = (Get-CimInstance Win32_LogicalDisk).FreeSpace
$FreeDiskSizeGB = $FreeDiskSize / 1073741824;
$FreeDiskSizeGB = "{0:N0}" -f $FreeDiskSizeGB;
$DiskSize = (Get-CimInstance Win32_LogicalDisk).Size;
$DiskSizeGB = $DiskSize / 1073741824;
$DiskSizeGB = "{0:N0}" -f $DiskSizeGB;
if ($DiskSize -gt 0)
{
$FreeDiskPercent = ($FreeDiskSizeGB / $DiskSizeGB) * 100;
$FreeDiskPercent = "{0:N0}" -f $FreeDiskPercent;
$UsedDiskSizeGB = $DiskSizeGB - $FreeDiskSizeGB;
$UsedDiskPercent = ($UsedDiskSizeGB / $DiskSizeGB) * 100;
$UsedDiskPercent = "{0:N0}" -f $UsedDiskPercent;
$FormattedDisk = "Disk " + $DiskID.ToString() + " " +
$UsedDiskSizeGB.ToString() + "GB" + " / " + $DiskSizeGB.ToString() + "GB " +
"(" + $UsedDiskPercent.ToString() + "%" + ")";
$FormattedDisks.Add($FormattedDisk);
}
else
{
$FormattedDisk = "Disk " + $DiskID.ToString() + " Empty";
$FormattedDisks.Add($FormattedDisk);
}
}
return $FormattedDisks;
}