2.6 פרויקט פתרון
# הגדרת פונקציה לשליפת מידע מהמחשב המקומי
function Get-ComputerInfo {
try {
# שליפת המידע על המחשב
$computerInfo = Get-WmiObject -Class Win32_OperatingSystem
$processorInfo = Get-WmiObject -Class Win32_Processor
$memoryInfo = Get-WmiObject -Class Win32_ComputerSystem
# הצגת המידע
$osName = $computerInfo.Caption
$osVersion = $computerInfo.Version
$ram = [math]::round($memoryInfo.TotalPhysicalMemory / 1GB, 2) # המרת זיכרון RAM ל-GB
$cpuCount = $processorInfo.Count
Write-Host "שם המחשב: $(hostname)"
Write-Host "מערכת הפעלה: $osName"
Write-Host "גרסת מערכת ההפעלה: $osVersion"
Write-Host "זיכרון RAM: $ram GB"
Write-Host "מספר מעבדים: $cpuCount"
} catch {
Write-Host "שגיאה בשליפת המידע. אנא ודא כי החיבור ל-WMI פעיל." -ForegroundColor Red
}
}
# פונקציה לעדכון המידע כל 10 שניות
function Monitor-ComputerStatus {
while ($true) {
# שליפת המידע בכל פעם מחדש
Clear-Host
Get-ComputerInfo
# המתנה של 10 שניות לפני העדכון הבא
Start-Sleep -Seconds 10
}
}
# קריאה לפונקציה שמבצעת את המעקב
Monitor-ComputerStatus