-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathData.psm1
94 lines (73 loc) · 2.21 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
Function Get-SystemSpecifications()
{
$UserInfo = Get-UserInformation;
$OS = Get-OS;
$Kernel = Get-Kernel;
$Uptime = Get-Uptime;
$Shell = Get-Shell;
$RAM = Get-RAM;
$Blank = Get-blank;
[System.Collections.ArrayList] $SystemInfoCollection =
$Blank,
$UserInfo,
$OS,
$Kernel,
$RAM,
$Uptime,
$Shell,
$Blank,
$Blank,
$Blank;
return $SystemInfoCollection;
}
Function Get-LineToTitleMappings()
{
$TitleMappings = @{
1 = "";
2 = "OS: ";
3 = "Kernel: ";
4 = "Memory: ";
5 = "Uptime: ";
6 = "Shell: ";
};
return $TitleMappings;
}
Function Get-blank
{
""
}
Function Get-UserInformation()
{
return $env:USERNAME + "@" + [System.Net.Dns]::GetHostName();
}
Function Get-OS()
{
return (Get-CimInstance Win32_OperatingSystem).Caption + " " +
(Get-CimInstance Win32_OperatingSystem).OSArchitecture;
}
Function Get-Kernel()
{
return (Get-CimInstance Win32_OperatingSystem).Version;
}
Function Get-Uptime()
{
$Uptime = (([DateTime](Get-CimInstance Win32_OperatingSystem).LocalDateTime) -
([DateTime](Get-CimInstance Win32_OperatingSystem).LastBootUpTime));
$FormattedUptime = $Uptime.Days.ToString() + "d " + $Uptime.Hours.ToString() + "h " + $Uptime.Minutes.ToString() + "m " + $Uptime.Seconds.ToString() + "s ";
return $FormattedUptime;
}
Function Get-Shell()
{
return "PowerShell $($PSVersionTable.PSVersion.ToString())";
}
Function Get-RAM()
{
$FreeRam = ([math]::Truncate((Get-CimInstance Win32_OperatingSystem).FreePhysicalMemory / 1KB));
$TotalRam = ([math]::Truncate((Get-CimInstance 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() + "%" + ")";
}