forked from jrussellfreelance/powershell-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AD-computers-html-report.ps1
48 lines (41 loc) · 1.08 KB
/
AD-computers-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
# This script retrieves all the computers listed in Active Directory and creates an html report.
$reportPath = $PSScriptRoot + "\ActiveDirectoryComputers.html"
# Grab list of computers in Active Directory
$servers = Get-ADComputer -Filter *
# Convert list to HTML
$serversHtml = $servers | Select-Object DNSHostName,Enabled,Name,ObjectClass,ObjectGUID,SamAccountName | ConvertTo-Html -Fragment -PreContent "<h2>Active Directory Computers</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>
"@
# Convert everything to HTML and output to file
ConvertTo-Html -Head $head -Body $serversHtml | Out-File $reportPath