forked from compwiz32/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-CPUCounts.ps1
More file actions
55 lines (31 loc) · 1.26 KB
/
Get-CPUCounts.ps1
File metadata and controls
55 lines (31 loc) · 1.26 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
#$Servers1 = Get-ADComputer -LDAPFilter “(&(objectcategory=computer)(OperatingSystem=*server*))” | Select-Object name
$serverlist = Import-Csv "C:\Scripts\Output\ServerList.csv"
[array]$fullCompObject = $null
#$Servers = Import-Csv "C:\Scripts\Output\ServerList.csv"
[array]$Servers = @Import-Csv "C:\Scripts\Output\ServerList.csv"
# $path = Split-Path -Path $MyInvocation.MyCommand.Path
foreach ($server in $Servers)
{
Write-Output $server
$CompModel = Get-WMIObject -Computer $server -Class Win32_computerSystem
$CompCores = Get-WMIObject -Computer $server -Class Win32_processor
$compProperty = @{Name=$server}
$compProperty += @{Model=$compModel.Model}
$compProperty += @{TotalCores=$compCores.Count}
$compObject = New-Object PSObject -Property $compProperty
$fullCompObject += $compObject
}
if ($fullCompObject)
{
foreach ($comp in $fullCompObject)
{
Write-Output "Name: $($comp.Name), Model: $($comp.Model), Total Cores: $($comp.TotalCores)"
}
if ((Read-Host "Export to CSV?") -like '*y*')
{
$fullCompObject | Select-Object Name,Model,TotalCores | Export-CSV -Path "$path\wmi.csv" -NoTypeInformation
Write-Output "CSV exported to: $path\wmi.csv"
}
} else {
Write-Output 'Something went wrong!'
}