-
Notifications
You must be signed in to change notification settings - Fork 0
/
SystemReportHTML.ps1
115 lines (74 loc) · 6.2 KB
/
SystemReportHTML.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<#
Generate a informative page about Laptop/desktop hardware and software information and give output in html
http://newdelhipowershellusergroup.blogspot.com/2011/10/generate-system-information-reports.html
www.amandhally.net/blog
#>
#### HTML Output Formatting #######
$a = "<style>"
$a = $a + "BODY{background-color:Lavender ;}"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}"
$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:PaleGoldenrod}"
$a = $a + "</style>"
################################################################################################
###### Global variables ####
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null
$vUserName = (Get-Item env:\username).Value ## This will get username using environment variable
$vComputerName = [Microsoft.VisualBasic.Interaction]::InputBox('Enter a computer name', 'Computer', "$env:computername") ## this is computer name using environment variable
$filepath = (Get-ChildItem env:\userprofile).value ## this is user profile using environment variable
if ($vComputerName -eq '' -or $null) {Exit}
ConvertTo-Html -Title "System Information for $vComputerName" -Body "<h1> Computer Name : $vComputerName </h1>" > "$filepath\$vComputerName.html"
################################################
# Hardware Information
#################################################
ConvertTo-Html -Body "<H1>HARDWARE INFORMATION </H1>" >> "$filepath\$vComputerName.html"
Get-WmiObject win32_bios -ComputerName $vComputerName | select Status,Version,PrimaryBIOS,Manufacturer,ReleaseDate,SerialNumber `
| ConvertTo-html -Body "<H2> BIOS Information</H2>" >> "$filepath\$vComputerName.html"
Get-WmiObject win32_DiskDrive -ComputerName $vComputerName | Select Model,SerialNumber,Description,MediaType,FirmwareRevision |ConvertTo-html -Body "<H2> Physical DISK Drives </H2>" >> "$filepath\$vComputerName.html"
get-WmiObject win32_networkadapter -ComputerName $vComputerName | Select Name,Manufacturer,Description ,AdapterType,Speed,MACAddress,NetConnectionID `
| ConvertTo-html -Body "<H2> Network Adapters</H2>" >> "$filepath\$vComputerName.html"
################################################
# OS Information
#################################################
ConvertTo-Html -Body "<H1>OS INFORMATION </H1>" >> "$filepath\$name.html"
get-WmiObject win32_operatingsystem -ComputerName $vComputerName | select Caption,Organization,InstallDate,OSArchitecture,Version,SerialNumber,BootDevice,WindowsDirectory,CountryCode `
| ConvertTo-html -Body "<H2> Operating System Information</H2>" >> "$filepath\$vComputerName.html"
Get-WmiObject win32_logicalDisk -ComputerName $vComputerName | select DeviceID,VolumeName,@{Expression={$_.Size /1Gb -as [int]};Label="Total Size(GB)"},@{Expression={$_.Freespace / 1Gb -as [int]};Label="Free Size (GB)"} `
| ConvertTo-html -Body "<H2> Logical DISK Drives </H2>" >> "$filepath\$vComputerName.html"
Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $vComputerName |
Select-Object Description, DHCPServer,
@{Name='IpAddress';Expression={$_.IpAddress -join '; '}},
@{Name='IpSubnet';Expression={$_.IpSubnet -join '; '}},
@{Name='DefaultIPgateway';Expression={$_.DefaultIPgateway -join '; '}},
@{Name='DNSServerSearchOrder';Expression={$_.DNSServerSearchOrder -join '; '}},
WinsPrimaryServer, WINSSecondaryServer| ConvertTo-html -Body "<H2>IP Address </H2>" >> "$filepath\$vComputerName.html"
################################################
# OS Information
#################################################
ConvertTo-Html -Body "<H1>SOFTWARE INFORMATION </H1>" >> "$filepath\$vComputerName.html"
# Huntington Software Tracking Keys
#ConvertTo-Html -Body "<H1>Huntington Software Registry Tracking Keys </H1>" >> "$filepath\$vComputerName.html"
$RegPath = "SOFTWARE\\HNB"
$REG = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine',$vComputerName)
$subkeys = $reg.OpenSubKey($RegPath).GetSubKeyNames()
$appList = $null
foreach($key in $SUBKEYS)
{
[Array]$tmpArray = @()
$app = $REG.OpenSubKey($RegPath+"\\"+$key)
$Release = $($app.GetValue("Release"))
$tmpArray = New-Object -TypeName psobject
$tmpArray | Add-Member -MemberType NoteProperty -Name "Application" -Value $key
$tmpArray | Add-Member -MemberType NoteProperty -Name "Release" -Value $Release
[Array]$appList += $tmpArray
}
$appList | ConvertTo-html -Head $a -Body "<H2>Huntington Software Registry Tracking Keys</H2>" >> "$filepath\$vComputerName.html"
Get-WmiObject win32_startupCommand -ComputerName $vComputerName | select Name,Location,Command,User,caption `
| ConvertTo-html -Body "<H2>Startup Softwares</H2>" >> "$filepath\$vComputerName.html"
Get-WmiObject win32_process -ComputerName $vComputerName | select Caption,ProcessId,@{Expression={$_.Vm /1mb -as [Int]};Label="VM (MB)"},@{Expression={$_.Ws /1Mb -as [Int]};Label="WS (MB)"} |sort "Vm (MB)" -Descending `
| ConvertTo-html -Head $a -Body "<H2> Running Processes</H2>" >> "$filepath\$vComputerName.html"
Get-WmiObject win32_Service | where {$_.StartMode -eq "Auto" -and $_.State -eq "stopped"} | Select Name,StartMode,State | ConvertTo-html -Head $a -Body "<H2> Services </H2>" >> "$filepath\$vComputerName.html"
$Report = "The Report is generated On $(get-date) by $((Get-Item env:\username).Value) on computer $((Get-Item env:\Computername).Value)"
$Report >> "$filepath\$vComputerName.html"
invoke-Expression "$filepath\$vComputerName.html"
#################### END of SCRIPT ####################################