Birden fazla Windows sunucusunun sistem bilgilerini toplamak ve merkezi bir rapora dönüştürmek, sistem yöneticileri için sık gereken bir işlemdir. PowerShell ile bu süreci tamamen otomatize edebilirsiniz.
Sistem Bilgileri Toplama Fonksiyonu
PowerShell
function Get-SystemInventory {
param([string[]]$ComputerNames)
$inventory = @()
foreach ($computer in $ComputerNames) {
try {
$os = Get-CimInstance -ComputerName $computer Win32_OperatingSystem
$cpu = Get-CimInstance -ComputerName $computer Win32_Processor | Select-Object -First 1
$disk = Get-CimInstance -ComputerName $computer Win32_LogicalDisk -Filter "DriveType=3"
$inventory += [PSCustomObject]@{
Sunucu = $computer
OS = $os.Caption
RAM_GB = [math]::Round($os.TotalVisibleMemorySize / 1MB, 2)
CPU = $cpu.Name
DiskBos_GB = [math]::Round(($disk | Measure-Object FreeSpace -Sum).Sum / 1GB, 2)
}
} catch { Write-Warning "$computer erisir: $($_.Exception.Message)" }
}
return $inventory
}
$rapor = Get-SystemInventory -ComputerNames @("SERVER01","SERVER02","SERVER03")
$rapor | Format-Table -AutoSize
$rapor | Export-Csv "system_inventory.csv" -NoTypeInformation
Ben localhost ile ilerleyeyim, zira kendi makinem! :)
