forked from JulianChow94/Windows-screenFetch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathData.psm1
More file actions
244 lines (200 loc) · 6.97 KB
/
Data.psm1
File metadata and controls
244 lines (200 loc) · 6.97 KB
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
Add-Type -AssemblyName System.Windows.Forms
Function Get-SystemSpecifications()
{
$UserInfo = Get-UserInformation;
$OS = Get-OS;
$Kernel = Get-Kernel;
$Uptime = Get-Uptime;
$Motherboard = Get-Mobo;
$Shell = Get-Shell;
$Displays = Get-Displays;
$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,
$Displays,
$WM,
$Font,
$CPU,
$GPU,
$RAM;
foreach ($Disk in $Disks)
{
[void]$SystemInfoCollection.Add($Disk);
}
return $SystemInfoCollection;
}
Function Get-LineToTitleMappings()
{
$TitleMappings = @{
0 = "";
1 = "OS: ";
2 = "Kernel: ";
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 $env:USERNAME + "@" + (Get-WmiObject Win32_OperatingSystem).CSName;
}
Function Get-OS()
{
return (Get-WmiObject Win32_OperatingSystem).Caption + " " +
(Get-WmiObject Win32_OperatingSystem).OSArchitecture;
}
Function Get-Kernel()
{
return (Get-WmiObject Win32_OperatingSystem).Version;
}
Function Get-Uptime()
{
$Uptime = ((Get-WmiObject Win32_OperatingSystem).ConvertToDateTime(
(Get-WmiObject Win32_OperatingSystem).LocalDateTime) -
(Get-WmiObject Win32_OperatingSystem).ConvertToDateTime(
(Get-WmiObject Win32_OperatingSystem).LastBootUpTime));
$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-Display()
{
# This gives the current resolution
$videoMode = Get-WmiObject -Class Win32_VideoController;
$Display = $videoMode.CurrentHorizontalResolution.ToString() + " x " + $videoMode.CurrentVerticalResolution.ToString() + " (" + $videoMode.CurrentRefreshRate.ToString() + "Hz)";
return $Display;
}
Function Get-Displays()
{
$Displays = New-Object System.Collections.Generic.List[System.Object];
# This gives the available resolutions
$monitors = Get-WmiObject -N "root\wmi" -Class WmiMonitorListedSupportedSourceModes
foreach($monitor in $monitors)
{
# Sort the available modes by display area (width*height)
$sortedResolutions = $monitor.MonitorSourceModes | sort -property {$_.HorizontalActivePixels * $_.VerticalActivePixels}
$maxResolutions = $sortedResolutions | select @{N="MaxRes";E={"$($_.HorizontalActivePixels) x $($_.VerticalActivePixels) "}}
$Displays.Add(($maxResolutions | select -last 1).MaxRes);
}
if ($Displays.Count -eq 1) {
return Get-Display
}
return $Displays;
}
Function Get-WM()
{
return "DWM";
}
Function Get-Font()
{
return "Segoe UI";
}
Function Get-CPU()
{
return (((Get-WmiObject Win32_Processor).Name) -replace '\s+', ' ');
}
Function Get-GPU()
{
return (Get-WmiObject Win32_DisplayConfiguration).DeviceName;
}
Function Get-RAM()
{
$FreeRam = ([math]::Truncate((Get-WmiObject Win32_OperatingSystem).FreePhysicalMemory / 1KB));
$TotalRam = ([math]::Truncate((Get-WmiObject Win32_ComputerSystem).TotalPhysicalMemory / 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() + "MB / " + $TotalRam.ToString() + " MB " + "(" + $UsedRamPercent.ToString() + "%" + ")";
}
Function Get-Disks()
{
$FormattedDisks = New-Object System.Collections.Generic.List[System.Object];
$NumDisks = (Get-WmiObject Win32_LogicalDisk).Count;
if ($NumDisks)
{
for ($i=0; $i -lt ($NumDisks); $i++)
{
$DiskID = (Get-WmiObject Win32_LogicalDisk)[$i].DeviceId;
$DiskSize = (Get-WmiObject Win32_LogicalDisk)[$i].Size;
if ($DiskSize -and $DiskSize -ne 0)
{
$FreeDiskSize = (Get-WmiObject Win32_LogicalDisk)[$i].FreeSpace
$FreeDiskSizeGB = $FreeDiskSize / 1073741824;
$FreeDiskSizeGB = "{0:N0}" -f $FreeDiskSizeGB;
$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;
}
else {
$DiskSizeGB = 0;
$FreeDiskSizeGB = 0;
$FreeDiskPercent = 0;
$UsedDiskSizeGB = 0;
$UsedDiskPercent = 100;
}
$FormattedDisk = "Disk " + $DiskID.ToString() + " " +
$UsedDiskSizeGB.ToString() + "GB" + " / " + $DiskSizeGB.ToString() + "GB " +
"(" + $UsedDiskPercent.ToString() + "%" + ")";
$FormattedDisks.Add($FormattedDisk);
}
}
else
{
$DiskID = (Get-WmiObject Win32_LogicalDisk).DeviceId;
$FreeDiskSize = (Get-WmiObject Win32_LogicalDisk).FreeSpace
$FreeDiskSizeGB = $FreeDiskSize / 1073741824;
$FreeDiskSizeGB = "{0:N0}" -f $FreeDiskSizeGB;
$DiskSize = (Get-WmiObject 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;
}