Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $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.
- $outputs = @()
- foreach($computer in $pc){
- $win32compsystem=get-wmiobject win32_computersystem -ComputerName $PC
- $win32cpu=Get-WmiObject Win32_Processor -ComputerName $PC
- $win32serial= Get-WmiObject win32_bios -ComputerName $PC
- $win32os= Get-WmiObject Win32_OperatingSystem
- if(test-connection $computer -BufferSize 16 -Count 1 -Quiet){
- $output =New-Object -TypeName PSObject -Property @{
- HostName = $win32compsystem.DNSHostName
- Manufacturer =$win32compsystem.Manufacturer
- Model = $win32compsystem.Model
- Ram = get-wmiobject win32_computersystem -ComputerName $PC | select @{Name="TotalPhysicalMemoryInMB";Expression={"{0:n2}" -f($_.TotalPhysicalMemory/1mb)}}
- CPU= $win32cpu.Name
- SeviceTag = $win32serial.SerialNumber
- OSName = $win32os.Caption
- OSBitType = $win32os.OSArchitecture
- }
- }
- Else{
- Add-Content c:\scripts\test.txt "$computer is not on" }
- }
- $outputs += $output|Format-list
- $outputs| Out-File "C:\Scripts\test.txt"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement