[PowerShell] / Get-ComputerInfo.ps1 Repository:
ViewVC logotype

Annotation of /Get-ComputerInfo.ps1

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : ian 1 ##################################################
2 :     #
3 :     # Written by Ian Cammarata
4 :     # Last Updated: 1:02 AM 3/29/2013
5 :     #
6 :     ##################################################
7 :     #
8 :     # Usage:
9 :     # Get-ComputerInfo < ip | computer name >
10 :     # Ex:
11 :     # Get-ComputerInfo 192.168.10.10
12 :     #
13 :     ##################################################
14 :     #
15 :     # Notes:
16 :     # -Monitor info requires Windows Vista or newer
17 :     # -Thermal info requires admin rights
18 :     #
19 :     ##################################################
20 :    
21 :     $ErrorActionPreference = "SilentlyContinue"
22 :    
23 :     $lookupPC = "."
24 :     IF ($args) { $lookupPC = $args[0] }
25 :    
26 :     IF ((Test-Connection -quiet -Count 1 $lookupPC) -eq $FALSE -AND $lookupPC -ne ".")
27 :     {
28 :     Write-Host -ForegroundColor RED "Could not resolve host name or PC not pingable."
29 :     EXIT
30 :     }
31 :    
32 :     $w32dd = Get-WmiObject -ComputerName $lookupPC Win32_DiskDrive
33 :     $w32ddCIMV2 = Get-Wmiobject -ComputerName $lookupPC Win32_DiskDrive -namespace "root\CIMV2"
34 :     $w32pm = Get-WmiObject -ComputerName $lookupPC Win32_PhysicalMedia
35 :     $storageFailPredict = Get-WmiObject -ComputerName $lookupPC -Namespace root\wmi -Class MSStorageDriver_FailurePredictStatus
36 :     $w32cs = Get-WmiObject -ComputerName $lookupPC -Class win32_computersystem
37 :     $w32os = Get-Wmiobject -ComputerName $lookupPC Win32_OperatingSystem
38 :     $w32b = Get-WmiObject -ComputerName $lookupPC -Class win32_bios
39 :     $w32mon = Get-WmiObject -ComputerName $lookupPC -Class WmiMonitorID -Namespace "root/wmi"
40 :     $therm = Get-Wmiobject -ComputerName $lookupPC MSAcpi_ThermalZoneTemperature -namespace "root/wmi"
41 :     $thermFormat = @{Expression={$_.InstanceName};Label="Thermal Sensor";width=25},@{Expression={($_.CurrentTemperature / 10 - 273.15) / (5/9) + 32};Label="Temp. (Deg F)";width=15}, @{Expression={($_.CurrentTemperature)};Label="Temp. (Kelvins)";width=15}
42 :    
43 :     #Write-Host -ForegroundColor Black -BackgroundColor White "########################################################"
44 :     #""
45 :     Write-Host -ForegroundColor Blue -BackgroundColor White "------------ Windows Info ------------"
46 :     "Comp Name:`t" + $w32dd.SystemName
47 :     "Domain:`t`t" + $w32cs.Domain
48 :     "Win Vers.:`t" + $w32os.Caption
49 :     ""
50 :    
51 :     Write-Host -ForegroundColor Blue -BackgroundColor White "------------ HDD Info ------------"
52 :     for ( $i = 0; $i -lt $w32dd.length; $i++ )
53 :     {
54 :     write-host "HDD Model:`t" $w32dd[$i].Model.Trim()
55 :     write-host "HDD SN:`t`t" $w32pm[$i].SerialNumber.Trim()
56 :     write-host "Size:`t`t" ([math]::round( $w32ddCIMV2[$i].Size / 1GB )) "GB"
57 :     write-host "Predict Fail:`t" $storageFailPredict[$i].PredictFailure
58 :     write-host "Fail Reason:`t" $storageFailPredict[$i].Reason
59 :     write-host
60 :     }
61 :    
62 :     Write-Host -ForegroundColor Blue -BackgroundColor White "------------ PC Info ------------"
63 :     "PC Mfr:`t`t" + $w32cs.Manufacturer
64 :     "PC Model:`t" + $w32cs.Model
65 :     "PC SN:`t`t" + $w32b.SerialNumber
66 :     "Memory:`t`t" + "{0:N1}" -f ( [math]::round( $w32cs.TotalPhysicalMemory / 1GB ) ) + " GB"
67 :     "BIOS Vers.:`t" + $w32b.SMBIOSBIOSVersion
68 :     write-host
69 :    
70 :     Write-Host -ForegroundColor Blue -BackgroundColor White "------------ Monitors ------------"
71 :     Foreach ( $monitor in $w32mon ){
72 :     $mdl = (($monitor.UserFriendlyName | foreach {[char]$_}) -join "").Trim([char]0)
73 :     $sn = (($monitor.SerialNumberID | foreach {[char]$_}) -join "").Trim([char]0)
74 :     $mfrName = (($monitor.ManufacturerName | foreach {[char]$_}) -join "").Trim([char]0)
75 :     if ( $mdl ) { write-host $mfrName $mdl "`tsn`t" $sn }
76 :     }
77 :     write-host
78 :    
79 :     Write-Host -ForegroundColor Blue -BackgroundColor White "------------ Thermal Info ------------"
80 :     IF ($therm)
81 :     {
82 :     $therm | Format-Table $thermFormat
83 :     #$therm | Format-Table $thermFormat | out-default
84 :     }
85 :     else { Write-Host -ForegroundColor Yellow "Thermal Info not available.`n" }
86 :     Write-Host -ForegroundColor Black -BackgroundColor White "########################################################"

Contact
ViewVC Help
Powered by ViewVC 1.0.4