-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsysinfo.ps1
More file actions
83 lines (75 loc) · 3.18 KB
/
sysinfo.ps1
File metadata and controls
83 lines (75 loc) · 3.18 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
$adminPasswordStatus = $null
$thermalState = $null
$osInfo = Get-CimInstance Win32_OperatingSystem
$computerInfo = Get-CimInstance Win32_ComputerSystem
$diskInfo = Get-CimInstance Win32_LogicalDisk
try {
[System.DirectoryServices.ActiveDirectory.Domain]::GetComputerDomain()
$domainJoined = 1
} catch {
$domainJoined = 0
}
Switch ($computerInfo.AdminPasswordStatus) {
0 {
$adminPasswordStatus = 'Disabled'
}
1 {
$adminPasswordStatus = 'Enabled'
}
2 {
$adminPasswordStatus = 'Not Implemented'
}
3 {
$adminPasswordStatus = 'Unknown'
}
Default {
$adminPasswordStatus = 'Unable to determine'
}
}
Switch ($computerInfo.ThermalState) {
1 {
$thermalState = 'Other'
}
2 {
$thermalState = 'Unknown'
}
3 {
$thermalState = 'Safe'
}
4 {
$thermalState = 'Warning'
}
5 {
$thermalState = 'Critical'
}
6 {
$thermalState = 'Non-recoverable'
}
Default {
$thermalState = 'Unable to determine'
}
}
$sysinfoObject = New-Object -TypeName psobject
$sysinfoObject | Add-Member -MemberType NoteProperty -Name OS -Value $osInfo.Caption
$sysinfoObject | Add-Member -MemberType NoteProperty -Name 'OSVersion' -Value $("$($osInfo.Version) Build $($osInfo.BuildNumber)")
$sysinfoObject | Add-Member -MemberType NoteProperty -Name ComputerName -Value $computerInfo.Name
if ($domainJoined -eq 1) {
$sysinfoObject | Add-Member -MemberType NoteProperty -Name Domain -Value $computerInfo.Domain
#$sysinfoObject | Add-Member -MemberType NoteProperty -Name Workgroup -Value $null
} else {
#$sysinfoObject | Add-Member -MemberType NoteProperty -Name Domain -Value $null
$sysinfoObject | Add-Member -MemberType NoteProperty -Name Workgroup -Value $computerInfo.Workgroup
}
$sysinfoObject | Add-Member -MemberType NoteProperty -Name AdminPasswordStatus -Value $adminPasswordStatus
$sysinfoObject | Add-Member -MemberType NoteProperty -Name ThermalState -Value $thermalState
$hwInfoObject = New-Object -TypeName psobject
$cimModel = Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object -Property Manufacturer,Model
$hwInfoObject | Add-Member -MemberType NoteProperty -Name Model -Value $cimModel
$cimCPU = Get-CimInstance -ClassName Win32_Processor | Select-Object -Property Name,NumberOfCores,MaxClockSpeed
$hwInfoObject | Add-Member -MemberType NoteProperty -Name CPU -Value $cimCPU.Name
$cimGPU = Get-CimInstance -ClassName Win32_VideoController | Select-Object -Property Description
$hwInfoObject | Add-Member -MemberType NoteProperty -Name GPU -Value $cimGPU
$sysinfoObject | Add-Member -MemberType NoteProperty -Name Owner -Value (Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object -Property RegisteredUser,Organization)
$sysinfoObject | Add-Member -MemberType NoteProperty -Name Hardware -Value $hwInfoObject
$sysinfoObject | Add-Member -MemberType NoteProperty -Name Disks -Value $diskInfo
return $sysinfoObject