top of page

PowerShell - Get SysInfo from text list of Computers

  • Writer: Jon Boyette
    Jon Boyette
  • Jan 11, 2022
  • 1 min read

Save as a namdedps1, Populate c:\temp\servers.txt with ALL servers to check/get sysinfo. Outputs to c:\temp\ServerDiscovery.csv, Includes - ComputerName, Make, Model, RAM, OS, CPU, LoggedOnUsers

#Specify the path the text file containing the computer names

$computers = Get-Content -Path "c:\temp\servers.txt"


# Creating an empty array, will be used later

$array= @()



foreach ($computer in $computers)

{

#Querying information about the computer

$query = Get-WmiObject -Class win32_computersystem -ComputerName $computer

$name = $query.Name

$make = $query.Manufacturer

$model = $query.Model

$ram = $query.TotalPhysicalMemory/1Gb

$os = (Get-WmiObject -Class win32_operatingsystem -ComputerName $computer).Caption

$cpu = (Get-WmiObject -Class Win32_processor -ComputerName $computer).Name

$users = $query.Username


# Now creating an populating the array. Change the collumns name if you wish

$Object = New-Object PSObject

$Object | Add-Member -MemberType NoteProperty -Name "ComputerName" -Value $name

$Object | Add-Member -MemberType NoteProperty -Name "Make" -Value $make

$Object | Add-Member -MemberType NoteProperty -Name "Model" -Value $model

$Object | Add-Member -MemberType NoteProperty -Name "RAM" -Value $ram

$Object | Add-Member -MemberType NoteProperty -Name "OS" -Value $os

$Object | Add-Member -MemberType NoteProperty -Name "CPU" -Value $cpu

$Object | Add-Member -MemberType NoteProperty -Name "LoggedOnUsers" -Value $users

$array += $Object

}


# Now exporting the array to a CSV file

$array | Export-Csv -Path c:\temp\ServerDiscovery.csv -NoTypeInformation


 
 
 

Recent Posts

See All
PowerShell - List All Domain SPNs

Save as same List_ALL_SPNs.ps1 or similar, this LDap calls the Domain for all Service Principal names and accounts related #Build LDAP...

 
 
 
PowerShell - Start-Monitoring

This is a great script used to Monitor and Email if a server is up or down, once ran, and smtp and from address is set, then run:...

 
 
 

Comments


Post: Blog2 Post
  • Facebook
  • Twitter
  • LinkedIn

©2022 by Boyette Technical Services. Proudly created with Wix.com

bottom of page