forked from PoeBlu/powershell-scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathIP Server Info.ps1
72 lines (66 loc) · 6.23 KB
/
IP Server Info.ps1
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
$iprange = Get-IPrange -start 10.33.20.1 -end 10.33.20.254
$list=@()
foreach ($ip in $iprange) {
$ok = Test-Connection $ip -Count 1 -Quiet
if ($ok) {
$hostn = [System.Net.Dns]::GetHostEntry($ip).HostName
#New-Object -TypeName PSObject -Property @{'Host'=$hostn;'IP'=$ip}
$list += $hostn
}
}
#$global:compname=@()
#$global:compname = Get-QADComputer -SizeLimit 0 -OSName 'Windows Server*' | where {$_.Name -like "AL1*"} | sort name
$report=@()
foreach ($name in $list)
{
$server = $name
$continue = $true
$row = "" | Select-Object Name,Manufacturer,Model,AssetTag,Serial,OS,CPU,"Number of CPUs","CPU Load",Memory,MemoryFree,IP,SubnetMask,DefaultGateway,Domain
try
{
$serial = Get-WmiObject -ComputerName $server -Class Win32_SystemEnclosure –erroraction Stop
}
catch
{
$continue = $false
$row.Name = $server + " is not accessible"
$report += $row
}
if ($continue)
{
$SystemInfo = Get-WmiObject -ComputerName $server -Class Win32_ComputerSystem
$OSInfo = Get-WmiObject -ComputerName $server -Class Win32_OperatingSystem
# $OSInfo1 = Get-WmiObject -ComputerName $name -Class Win32_OperatingSystem
$Proc = Get-WmiObject -ComputerName $server -Class "win32_processor" | select -First 1
$CPULoad = $Proc | Measure-Object -Property LoadPercentage -Average | select Average
$Net = get-wmiobject -computername $server -Class Win32_NetworkAdapterConfiguration | where {$_.Ipaddress.length -gt 0}
# $row = "" | Select-Object Name,Manufacturer,Model,AssetTag,Serial,OS,CPU,"Number of CPUs","CPU Load",Memory,MemoryFree,IP,SubnetMask,DefaultGateway,Domain
$row.Name = $SystemInfo.Name
# $row.Role = $OSInfo.Description
$row.Manufacturer = $SystemInfo.Manufacturer
$row.Model = $SystemInfo.Model
$row.AssetTag = $serial.SMBIOSAssetTag
$row.Serial = $serial.serialnumber
$row.OS = $OSInfo.Caption + " " + $OSInfo.CSDVersion
$row.CPU = $Proc.Name
$row."Number of CPUs" = $SystemInfo.NumberOfProcessors
$row."CPU Load" = ([string]$CPULoad.Average) + "%"
$row.Memory = "{0:N2}" -f ($OSInfo.TotalVisibleMemorySize / 1MB)+" GB"
$row.MemoryFree = "{0:N2}" -f ($OSinfo.FreePhysicalMemory / 1MB)+" GB"
$row.IP = $Net.IPAddress | select -First 1
$row.SubnetMask = $Net.IPSubnet | select -First 1
$row.DefaultGateway = $Net.DefaultIPGateway | select -First 1
# $row.WINS = $Net.WINSPrimaryServer
# $row.DNS = $Net.DNSServerSearchOrder
# foreach ($dns in $Net.DNSServerSearchOrder)
# {
# $row.DNS += $dns
# }
# $row.DNSSuffix = $Net.DNSDomainSuffixSearchOrder
$row.Domain = $SystemInfo.Domain
$report += $row
}
}
#$report | Export-Csv 'c:\Users\stiles.john\Desktop\Tools\Server Info\Endo Serverinfo.csv' -NoTypeInformation
#$serverMem = (Get-WmiObject -Class CIM_PhysicalMemory -ComputerName $Name | Measure-Object -Property Capacity -Sum)
#"{0:N0}" -f ($servermem.sum / 1GB) + " GB Total Memory"