-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-RemoteComputerInfo.ps1
More file actions
93 lines (68 loc) · 3.29 KB
/
Get-RemoteComputerInfo.ps1
File metadata and controls
93 lines (68 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
function Get-RemoteComputerInfo {
<#
.SYNOPSIS
Get Computer Information
.DESCRIPTION
Get Computer information for remote computers
.PARAMETER RemoteComputer
RemoteComputer
.EXAMPLE
Get-RemoteComputerInfo -RemoteComputer $env:COMPUTERNAME
Get-RemoteComputerInfo -RemoteComputer 'Computername'
run against several computers
$Data = import-csv c:\temp\servers.csv
foreach($D in $Data){Get-RemoteComputerInfo -RemoteComputer $D.name}
.NOTES
General notes
Disclaimer, run this at your own risk, supported AS-IS
#>
Param(
[parameter(Mandatory=$true)]
[String]
$RemoteComputer
)
#DataCollect
$Procs = Get-Process -ComputerName $RemoteComputer
$Disk = Get-WmiObject Win32_LogicalDisk -ComputerName $RemoteComputer | Where-Object{$_.DeviceID -like 'C:'}
$ComputerInfo = Get-WMIObject -class Win32_ComputerSystem -ComputerName $RemoteComputer
$OSInfo = Get-WmiObject Win32_OperatingSystem -ComputerName $RemoteComputer
$CPUInfo = Get-WmiObject Win32_Processor
$PhysicalMemory = Get-WmiObject CIM_PhysicalMemory -ComputerName $RemoteComputer | Measure-Object -Property capacity -Sum | % {[math]::round(($_.sum / 1GB),2)}
#Math
$OSTotalVirtualMemory = [math]::round($OSInfo.TotalVirtualMemorySize / 1MB, 2)
$OSTotalVisibleMemory = [math]::round(($OSInfo.TotalVisibleMemorySize / 1MB), 2)
$Size = $([math]::Round(((($Disk.Size)/1024)/1024/1024)))
$Freespace = $([math]::Round(((($Disk.FreeSpace)/1024)/1024/1024)))
#Arrays
$Object = @()
#FormatOutput
$hash = @{
Computername = $RemoteComputer
ProcessCount = $Procs.Count
RunTime = $(Get-date -Format "yyyy-MM-dd_hh:mm")
FreeDiskspace = "$FreeSpace" #+" GB"
TotalDiskSize = "$Size" #+" GB"
DiskDrivename = $Disk.DeviceID
ActiveUser = $ComputerInfo.UserName
Manufacturer = $ComputerInfo.Manufacturer
Model = $ComputerInfo.Model
CPUName = $CPUInfo.Name
CPUDescription = $CPUInfo.DESCRIPTION
CPUCores = $CPUInfo.NumberofCores
OSName = $OSInfo.Caption
OSVersion = $OSInfo.Version
TotalPhysicalMem= "$PhysicalMemory" #+ " GB"
TotalVirtualMem = $OSTotalVirtualMemory
TotalVisibleMem = $OSTotalVisibleMemory
LastBootTime = $OSInfo.LastBootUpTime
SerialNumber = $OSInfo.SerialNumber
OSType = $OSInfo.OSType
OSArchitecture = $OSInfo.OSArchitecture
}
$Object += New-Object PSObject -Property $hash
#Result
$Object
}
#Help Get-RemoteComputerInfo
#Help Get-RemoteComputerInfo -Examples
Get-RemoteComputerInfo -RemoteComputer $env:COMPUTERNAME