-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGet-ComputerInfoFromList.ps1
More file actions
23 lines (19 loc) · 941 Bytes
/
Copy pathGet-ComputerInfoFromList.ps1
File metadata and controls
23 lines (19 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Get-ComputerInfoFromList.ps1
# Gathers computer info from a list of PC names and appends to a CSV
# Requires PowerShell remoting enabled on targets
# --- Configuration ---
$PCListFile = "C:\Temp\Computerlist.txt"
$OutputFile = "C:\Temp\Computerdata.csv"
# ---------------------
Write-Host "--- Gathering Computer Info from $PCListFile ---" -ForegroundColor Cyan
foreach ($pcname in Get-Content $PCListFile) {
if (Test-Connection -ComputerName $pcname -Quiet -Count 1) {
Write-Host "Querying $pcname ..." -ForegroundColor Yellow
Invoke-Command -ComputerName $pcname -ScriptBlock {
Get-ComputerInfo | Select-Object CSName, WindowsProductName, WindowsVersion, OSVersion, OSHardwareAbstractionLayer
} | Out-File -Append $OutputFile
} else {
Write-Host "Skipping $pcname (unreachable)" -ForegroundColor Red
}
}
Write-Host "Done. Results saved to $OutputFile" -ForegroundColor Green