forked from brianary/scripts
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathGet-SystemDetails.ps1
185 lines (176 loc) · 5.04 KB
/
Get-SystemDetails.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
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
<#
.SYNOPSIS
Collects some useful system hardware and operating system details via CIM.
.OUTPUTS
System.Management.Automation.PSCustomObject with properties about the computer:
* Name: The computer name.
* Status: The reported computer status name.
* Manufacturer: The reported computer manufacturer name.
* Model: The reported computer model name.
* PrimaryOwnerName: The reported name of the owner of the computer, if available.
* Memory: The reported memory in the computer, and amount unused.
* OperatingSystem: The name and type of operating system used by the computer.
* Processors: CPU hardware details.
* Video: Video controller hardware name.
* Drives: Storage drives found on the computer.
* Shares: The file shares configured, if any.
* NetVersions: The versions of .NET on the system.
.FUNCTIONALITY
System and updates
.LINK
https://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions
.LINK
https://vdc-repo.vmware.com/vmwb-repository/dcr-public/3d076a12-29a2-4d17-9269-cb8150b5a37f/8b5969e2-1a66-4425-af17-feff6d6f705d/doc/class_CIM_OperatingSystem.html
.LINK
Get-CimInstance
.EXAMPLE
Get-SystemDetails.ps1
Name : DEEPTHOUGHT
Status : OK
Manufacturer : Microsoft Corporation
Model : Surface Pro 4
PrimaryOwnerName :
Memory : 3.93 GiB (25.68 % free)
OperatingSystem : Microsoft Windows 10 Pro
OSVersion : 10.0.14393
OSUpdate : 1607
OSType : WINNT
OSArchitecture : 64-bit
Processors : Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz
Video : NVIDIA GeForce GTX 670
Drives : C: 118 GiB (31.47 % free)
Shares :
NetVersions : {v4.6.2+win10ann, v3.5, v2.0.50727, v3.0}
#>
#Requires -Version 3
[CmdletBinding()][OutputType([Management.Automation.PSCustomObject])] Param()
$cs = Get-CimInstance CIM_ComputerSystem
$os = Get-CimInstance CIM_OperatingSystem
[pscustomobject]@{
Name = $cs.Name
Status = $cs.Status
Manufacturer = $cs.Manufacturer
Model = $cs.Model
PrimaryOwnerName = $cs.PrimaryOwnerName
Memory = (Format-ByteUnits $cs.TotalPhysicalMemory -si -dot 2) +
" ($('{0:p}' -f (1KB*$os.FreePhysicalMemory/$cs.TotalPhysicalMemory)) free)"
OperatingSystem = $os.Caption + ' ' + $os.CSDVersion
OSVersion = $os.Version
OSUpdate =
if($os.OSType -eq 18 -and $os.Version -like '10.*')
{
switch($os.BuildNumber)
{
22621 {'22H2'}
22000 {'22H1'}
19044 {'21H2'}
19043 {'21H1'}
19042 {'20H2'}
19041 {'2004'}
18363 {'1909'}
18362 {'1903'}
17763 {'1809'}
17134 {'1803'}
16299 {'1709'}
15063 {'1703'}
14393 {'1607'}
10586 {'1511'}
10240 {'1507'}
}
}
OSType =
switch($os.OSType)
{
0 {'Unknown'}
1 {$os.OtherTypeDescription}
2 {'MACOS'}
3 {'ATTUNIX'}
4 {'DGUX'}
5 {'DECNT'}
6 {'Tru64 UNIX'}
7 {'OpenVMS'}
8 {'HPUX'}
9 {'AIX'}
10 {'MVS'}
11 {'OS400'}
12 {'OS/2'}
13 {'JavaVM'}
14 {'MSDOS'}
15 {'WIN3x'}
16 {'WIN95'}
17 {'WIN98'}
18 {'WINNT'}
19 {'WINCE'}
20 {'NCR3000'}
21 {'NetWare'}
22 {'OSF'}
23 {'DC/OS'}
24 {'Reliant UNIX'}
25 {'SCO UnixWare'}
26 {'SCO OpenServer'}
27 {'Sequent'}
28 {'IRIX'}
29 {'Solaris'}
30 {'SunOS'}
31 {'U6000'}
32 {'ASERIES'}
33 {'HP NonStop OS'}
34 {'HP NonStop OSS'}
35 {'BS2000'}
36 {'LINUX'}
37 {'Lynx'}
38 {'XENIX'}
39 {'VM'}
40 {'Interactive UNIX'}
41 {'BSDUNIX'}
42 {'FreeBSD'}
43 {'NetBSD'}
44 {'GNU Hurd'}
45 {'OS9'}
46 {'MACH Kernel'}
47 {'Inferno'}
48 {'QNX'}
49 {'EPOC'}
50 {'IxWorks'}
51 {'VxWorks'}
52 {'MiNT'}
53 {'BeOS'}
54 {'HP MPE'}
55 {'NextStep'}
56 {'PalmPilot'}
57 {'Rhapsody'}
58 {'Windows 2000'}
59 {'Dedicated'}
60 {'OS/390'}
61 {'VSE'}
62 {'TPF'}
63 {'Windows (R) Me'}
64 {'Caldera Open UNIX'}
65 {'OpenBSD'}
66 {'Not Applicable'}
67 {'Windows XP'}
68 {'z/OS'}
69 {'Microsoft Windows Server 2003'}
70 {'Microsoft Windows Server 2003 64-Bit'}
71 {'Windows XP 64-Bit'}
72 {'Windows XP Embedded'}
73 {'Windows Vista'}
74 {'Windows Vista 64-Bit'}
75 {'Windows Embedded for Point of Service'}
76 {'Microsoft Windows Server 2008'}
77 {'Microsoft Windows Server 2008 64-Bit'}
}
OSArchitecture = $os.OSArchitecture
Processors = (Get-CimInstance CIM_Processor |
Select-Object -ExpandProperty Name |
ForEach-Object {$_ -replace '\s{2,}',' '})
Video = Get-CimInstance CIM_VideoController |Select-Object -ExpandProperty Name
Drives = (Get-CimInstance CIM_StorageVolume |
Where-Object {$_.DriveType -eq 3 -and $_.DriveLetter -and $_.Capacity} |
Sort-Object DriveLetter |
ForEach-Object {"$($_.DriveLetter) $(Format-ByteUnits $_.Capacity -si -dot 2) ($('{0:p}' -f ($_.FreeSpace/$_.Capacity)) free)"})
Shares= (Get-CimInstance Win32_Share |
Where-Object {$_.Type -eq 0} |
ForEach-Object {"$($_.Name)=$($_.Path)"})
NetVersions = Get-DotNetFrameworkVersions.ps1
}