#Get the computer list $servers = Get-Content C:\Data Collection\Computer list.txt #Run the commands for each computer in the list $infoColl = @() Foreach ($s in $servers) { $ComputerSystem = Get-WmiObject Win32_ComputerSystem -ComputerName $s #Get ComputerSystem Information $BIOS = Get-WmiObject Win32_BIOS -ComputerName $s #Get BIOS Information $CPUInfo = Get-WmiObject Win32_Processor -ComputerName $s #Get CPU Information $OSInfo = Get-WmiObject Win32_OperatingSystem -ComputerName $s #Get OS Information #Get Memory Information. The data will be shown in a table as MB, rounded to the nearest second decimal. $PhysicalMemory = Get-WmiObject CIM_PhysicalMemory -ComputerName $s | Measure-Object -Property capacity -Sum | % { [Math]::Round(($_.sum / 1GB), 2) } Foreach ($CPU in $CPUInfo) { $infoObject = New-Object PSObject #The following add data to the infoObjects. Add-Member -inputObject $infoObject -memberType NoteProperty -name "Computer Name" -value $CPU.SystemName Add-Member -inputObject $infoObject -memberType NoteProperty -name "Install Date" -value $OSInfo.InstallDate Add-Member -inputObject $infoObject -memberType NoteProperty -name "Processor" -value $CPU.Name Add-Member -inputObject $infoObject -memberType NoteProperty -name "Serial" -value $BIOS.SerialNumber Add-Member -inputObject $infoObject -memberType NoteProperty -name "Model" -value $ComputerSystem.model Add-Member -inputObject $infoObject -memberType NoteProperty -name "User Name" -value $ComputerSystem.UserName Add-Member -inputObject $infoObject -memberType NoteProperty -name "OS Name" -value $OSInfo.Caption Add-Member -inputObject $infoObject -memberType NoteProperty -name "OS Version" -value $OSInfo.Version Add-Member -inputObject $infoObject -memberType NoteProperty -name "Installed Memory" -value $PhysicalMemory $infoObject #Output to the screen for a visual feedback. $infoColl += $infoObject } } $infoColl | Export-Csv -path C:\Data Collection\Computer_Inventory_$((Get-Date).ToString('MM-dd-yyyy')).csv -NoTypeInformation #Export the results in csv file.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)