Back to Resources
Level
Script
General
Inconsistent hardware across an IT environment can lead to performance issues, security risks, and unnecessary support tickets. This script ensures that all Windows devices meet predefined minimum standards for CPU, RAM, and storage, helping IT teams enforce baseline compliance and proactively address underperforming systems before they become a problem.
This script retrieves system hardware details—including CPU core count, total RAM, and disk space—and compares them against the minimum values defined using Level’s custom fields (cf_minimum_cpu, cf_minimum_ram, and cf_minimum_storage). If any component falls below the defined threshold, an alert is generated. Additionally, the script checks if the primary disk is an SSD, warning if a slower HDD is in use. When integrated into Level as a script-based monitor, this ensures that non-compliant devices trigger alerts, enabling IT teams to take action quickly.
1<#
2This resource is provided as a convenience for Level users. We cannot
3guarantee it will work in all environments. Please test before deploying
4to your production environment. We welcome contributions to our community
5library
6
7Level Library
8https://level.io/library/script-windows-monitor-device-standards
9#>
10
11# Define minimum standards
12$minCores = {{cf_minimum_cpu}}
13$minRAM = {{cf_minimum_ram}} # in GB
14$minDiskSpace = {{cf_minimum_storage}} # in GB
15$standardsBypass = {{cf_standards_bypass}}
16Write-Host "Current STANDARDS_BYPASS value: $standardsBypass"
17
18# Check for standards bypass
19if ($standardsBypass -eq $true -or $standardsBypass -eq "1") {
20 Write-Host "Standards check bypassed by configuration"
21 exit 0
22}
23
24# Check CPU Cores
25$cpuCores = (Get-CimInstance Win32_Processor | Measure-Object -Property NumberOfLogicalProcessors -Sum).Sum
26
27# Check RAM
28$totalMemoryBytes = (Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory
29$totalMemoryGB = [math]::Round($totalMemoryBytes / 1GB, 2)
30
31# Check Disk Space
32$drives = Get-WmiObject Win32_LogicalDisk | Where-Object { $_.DriveType -eq 3 } # 3 is for local disk
33$totalDiskSpaceGB = 0
34foreach ($drive in $drives) {
35 $totalDiskSpaceGB += [math]::Round($drive.Size / 1GB, 2)
36}
37
38# Prepare to collect issues
39$issues = @()
40
41# Check CPU
42if ($cpuCores -lt $minCores) {
43 $issues += "ALERT: CPU has $cpuCores cores, below the minimum requirement of $minCores cores."
44}
45
46# Check RAM
47if ($totalMemoryGB -lt $minRAM) {
48 $issues += "ALERT: System has $totalMemoryGB GB of RAM, below the minimum requirement of $minRAM GB."
49}
50
51# Check Disk Space
52if ($totalDiskSpaceGB -lt $minDiskSpace) {
53 $issues += "ALERT: Total disk space is $totalDiskSpaceGB GB, below the minimum requirement of $minDiskSpace GB."
54}
55
56# Check if the disk is an SSD
57$DiskType = Get-PhysicalDisk | Where-Object { $_.DeviceID -eq "0" } | select -ExpandProperty MediaType
58if ($DiskType -notlike "SSD") {
59 $issues += "ALERT: The primary disk is not an SSD, but is a $DiskType."
60}
61
62# Output results
63if ($issues.Count -gt 0) {
64 Write-Host ($issues -join "`n")
65 exit 1
66} else {
67 Write-Host "System check passed:`n- CPU cores: $cpuCores (min: $minCores)`n- RAM: $totalMemoryGB GB (min: $minRAM GB)`n- Disk space: $totalDiskSpaceGB GB (min: $minDiskSpace GB)"
68 exit 0
69}
Windows Monitor - Device Standards
This PowerShell script checks if a Windows system meets minimum hardware requirements defined through Level Custom Fields. It verifies CPU cores, RAM, disk space, and SSD presence against specified thresholds (cf_minimum_cpu, cf_minimum_ram, cf_minimum_storage). The script collects any violations in an array and outputs either a list of alerts for failed checks or a confirmation message with current specifications if all checks pass, exiting with status code 1 or 0 respectively.
PowerShell
100
Local system
Explore more automations, scripts, and policies to further enhance your IT operations.