-
Notifications
You must be signed in to change notification settings - Fork 61
/
AD-computers-network-html-report.ps1
75 lines (63 loc) · 1.88 KB
/
AD-computers-network-html-report.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
# This script retrieves all the computers listed in Active Directory, tests their network settings, and creates an html report.
# NOTE: test-server.ps1 is included in this directory, and it is required for this script to work.
. "$PSScriptRoot\test-server.ps1"
$reportPath = $PSScriptRoot + "\ActiveDirectoryComputersNetwork.html"
# Grab list of computers in Active Directory
$servers = Get-ADComputer -Filter *
$serversNet = @()
foreach ($server in $servers) {
Write-Host "Testing "$server.DNSHostName
$results = Test-Server -ComputerName $server.DNSHostName
$serversNet += $results
}
$serversHtml = $serversNet | ConvertTo-Html -Fragment -PreContent "<h2>AD Computers - Network Status</h2>"
# Create HTML file
$head = @"
<title>AD Computer List</title>
<style>
body {
background-color: #282A36;
font-family: sans-serif;
}
h1 {
color: #FF7575;
}
h2 {
color: #E56969;
}
table {
background-color: #363949;
border-collapse: collapse;
}
td {
border: 2px solid #282A36;
background-color: #363949;
color: #FF7575;
padding: 5px;
}
th {
border: 2px solid #282A36;
background-color: #363949;
color: #FF7575;
text-align: left;
padding: 5px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
function filter(element) {
var value = `$(element).val().toLowerCase();
`$("table > tr").hide().filter(function() {
return `$(this).children('td:first-child').text().toLowerCase().indexOf(value) > -1;
}).show();
}
`$('#search').keyup(function() {
filter(this);
});
</script>
"@
$searchbar = @"
<input type='text' placeholder='Search by DNS Host Name...' id='search' />
"@
# Convert everything to HTML and output to file
ConvertTo-Html -Head $head -Body "$searchbar$serversHtml" | Out-File $reportPath