-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab_wmi.ps1
50 lines (32 loc) · 1.36 KB
/
lab_wmi.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
$continue = $false
$result = 'ddd' |
foreach {
$srv = $_
try {
$server = Get-WmiObject -ea stop -Class win32_computerSystem -ComputerName $srv
$continue = $true
} catch {
"Failed to get wmi for $srv"
}
if($continue){
$cpu = Get-WmiObject -class win32_Processor -ComputerName $_ | select -First 1
$os = Get-WmiObject -Class win32_operatingSystem -ComputerName $_
$system = @{}
$system.Name = $server.Name
$system.Model = $server.Model
$system.Make = $server.Manufacturer
$system.Memory = $server.TotalPhysicalMemory
$system.CPUs = $server.NumberOfProcessors
$system.speed = $cpu.MaxClockSpeed
$system.Windows = $os.Caption
$system.SP = $os.ServicePackmajorVersion
if(($os.version -split '\.')[0] -ge 6 ){
$system.Cores = $cpu.NumberOfCores
$system.LogProc = $cpu.NumberOfLogicalProcessors
} else {
$system.CPUs = ""
$system.Cores = $server.NumberOfProcessors
}
New-Object -TypeName PSObject -Property $system
}
}