-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystemperformance
More file actions
44 lines (41 loc) · 1.48 KB
/
systemperformance
File metadata and controls
44 lines (41 loc) · 1.48 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
# Import the CIM module
Import-Module -Name 'CIM'
# Get the performance counters for the CPU, DPC, memory, disk, and disk latency
$cpu = Get-CimInstance -ClassName 'Win32_PerfFormattedData_PerfOS_Processor'
$dpc = Get-CimInstance -ClassName 'Win32_PerfFormattedData_PerfOS_System'
$memory = Get-CimInstance -ClassName 'Win32_PerfFormattedData_PerfOS_Memory'
$disk = Get-CimInstance -ClassName 'Win32_PerfFormattedData_PerfDisk_PhysicalDisk'
$diskLatency = Get-CimInstance -ClassName 'Win32_PerfFormattedData_PerfDisk_LogicalDisk'
# Filter the endpoints that meet the criteria
$endpoints = $cpu | Where-Object {
$_.PercentProcessorTime -gt 80
} | Select-Object -ExpandProperty DeviceID
$endpoints = $endpoints | Where-Object {
$dpc | Where-Object {
$_.Name -eq $endpoints -and $_.PercentDPCTime -gt 15
}
}
$endpoints = $endpoints | Where-Object {
$memory | Where-Object {
$_.Name -eq $endpoints -and $_.AvailableMbytes -lt 250
}
}
$endpoints = $endpoints | Where-Object {
$diskLatency | Where-Object {
$_.Name -eq $endpoints -and ($_.AvgDiskReadQueueLength -gt 50 -or $_.AvgDiskWriteQueueLength -gt 50)
}
}
$endpoints = $endpoints | Where-Object {
$disk | Where-Object {
$_.Name -eq $endpoints -and ($_.FreeMegabytes -lt 1500)
}
}
# Check if any endpoints were found
if ($endpoints -eq $null) {
Write-Output "There are no endpoints that meet the criteria."
} else {
# Print the details of each endpoint
$endpoints | ForEach-Object {
Write-Output "Endpoint: $_"
}
}