foreach ($Computer in $ComputersInOU) {
$ComputerName = $Computer.Name
Write-Host "Retrieving configuration for: $ComputerName"
try {
# Get Operating System details
$OSInfo = Get-WmiObject -Class Win32_OperatingSystem -ComputerName $ComputerName -ErrorAction Stop
Write-Host " OS: $($OSInfo.Caption) Build: $($OSInfo.BuildNumber)"
# Get System details
$SystemInfo = Get-WmiObject -Class Win32_ComputerSystem -ComputerName $ComputerName -ErrorAction Stop
Write-Host " Manufacturer: $($SystemInfo.Manufacturer), Model: $($SystemInfo.Model)"
# Get Disk Space (example for C: drive)
$DiskInfo = Get-WmiObject -Class Win32_LogicalDisk -Filter "DeviceID='C:'" -ComputerName $ComputerName -ErrorAction Stop
if ($DiskInfo) {
Write-Host " C: Drive Free Space: $([Math]::Round($DiskInfo.FreeSpace / 1GB, 2)) GB"
}
# Add more WMI queries for other desired information (e.g., network, installed software)
} catch {
Write-Warning "Could not retrieve information from $ComputerName: $($_.Exception.Message)"
}
}