Advertisement
Guest User

Untitled

a guest
Jul 17th, 2017
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $PC = Get-Content -Path "C:\Scripts\pc name.txt"  #grabs a list of computer names. The names are formatted one per line. Names were generated with Net view in cmd then formatted to work properly afterwards.  
  2. $outputs = @()
  3.  
  4. foreach($computer in $pc){
  5. $win32compsystem=get-wmiobject win32_computersystem -ComputerName $PC
  6. $win32cpu=Get-WmiObject Win32_Processor -ComputerName $PC  
  7. $win32serial= Get-WmiObject win32_bios -ComputerName $PC
  8. $win32os= Get-WmiObject Win32_OperatingSystem
  9.  
  10.     if(test-connection $computer -BufferSize 16 -Count 1 -Quiet){
  11.     $output =New-Object -TypeName PSObject -Property @{
  12.  
  13. HostName = $win32compsystem.DNSHostName
  14. Manufacturer =$win32compsystem.Manufacturer
  15. Model = $win32compsystem.Model
  16. Ram = get-wmiobject win32_computersystem -ComputerName $PC | select @{Name="TotalPhysicalMemoryInMB";Expression={"{0:n2}" -f($_.TotalPhysicalMemory/1mb)}}
  17. CPU= $win32cpu.Name
  18. SeviceTag = $win32serial.SerialNumber
  19. OSName = $win32os.Caption
  20. OSBitType = $win32os.OSArchitecture
  21. }
  22.  
  23. }
  24.     Else{
  25.         Add-Content c:\scripts\test.txt "$computer is not on" }
  26.         }
  27.  
  28.  
  29. $outputs += $output|Format-list
  30.  
  31. $outputs| Out-File "C:\Scripts\test.txt"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement