-
Notifications
You must be signed in to change notification settings - Fork 63
/
Server-Audit.ps1
64 lines (54 loc) · 2.58 KB
/
Server-Audit.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
# Server-Audit.ps1
# Pings a list of servers contained in the text file servers.txt and if the server responds, returns information from each server
#
# mmessano
# 12-5-2012
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null
function getwmiinfo ($svr) {
# Get ComputerSystem info and write it to a CSV file
gwmi -query "select * from
Win32_ComputerSystem" -computername $svr |
select Name, Model, Manufacturer, DNSHostName, CurrentTimeZone,
Domain, NumberOfProcessors, NumberOfLogicalProcessors,
SystemType, TotalPhysicalMemory, PrimaryOwnerName | export-csv -path .\$svr\BOX_ComputerSystem.csv -noType
# Get OperatingSystem info and write it to a CSV file
gwmi -query "select * from
Win32_OperatingSystem" -computername $svr |
select Name, Version, FreePhysicalMemory, OSLanguage, OSProductSuite,
OSType, ServicePackMajorVersion, ServicePackMinorVersion | export-csv -path .\$svr\BOX_OperatingSystem.csv -noType
# Get NetworkAdapter info and write it to a CSV file
# gwmi -Query "select * from Win32_NetworkAdapterConfiguration" -ComputerName $srv |
# select Description, IPAddress, DefaultIPGateway
# Get PhysicalMemory info and write it to a CSV file
gwmi -query "select * from
Win32_PhysicalMemory" -computername $svr | select Name, Capacity, DeviceLocator,
Tag | export-csv -path .\$svr\BOX_PhysicalMemory.csv -noType
# Get LogicalDisk info and write it to a CSV file
gwmi -query "select * from Win32_LogicalDisk
where DriveType=3" -computername $svr | select Name, FreeSpace,
Size | export-csv -path .\$svr\BOX_LogicalDisk.csv -noType
"
}
$Adapters = Get-WmiObject -ComputerName $Target Win32_NetworkAdapterConfiguration
$IPInfo = @()
Foreach ($Adapter in ($Adapters | Where {$_.IPEnabled -eq $True}))
{
$Details = "" | Select Description, "Physical address", "IP Address / Subnet Mask", "Default Gateway", "DHCP Enabled", DNS, WINS
$Details.Description = "$($Adapter.Description)"
$Details."Physical address" = "$($Adapter.MACaddress)"
If ($Adapter.IPAddress -ne $Null) {
$Details."IP Address / Subnet Mask" = "$($Adapter.IPAddress)/$($Adapter.IPSubnet)"
$Details."Default Gateway" = "$($Adapter.DefaultIPGateway)"
}
If ($Adapter.DHCPEnabled -eq "True") {
$Details."DHCP Enabled" = "Yes"
}
Else {
$Details."DHCP Enabled" = "No"
}
If ($Adapter.DNSServerSearchOrder -ne $Null) {
$Details.DNS = "$($Adapter.DNSServerSearchOrder)"
}
$Details.WINS = "$($Adapter.WINSPrimaryServer) $($Adapter.WINSSecondaryServer)"
$IPInfo += $Details
}