Skip to content

Commit

Permalink
Renamed script, and added a new one.
Browse files Browse the repository at this point in the history
  • Loading branch information
JacFearsome committed Jan 8, 2018
1 parent 88c8224 commit 4ccce03
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
debug.log
25 changes: 5 additions & 20 deletions AD-computers-html-report.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
$reportPath = $PSScriptRoot + "\ActiveDirectoryComputers.html"

# 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
Expand Down Expand Up @@ -38,23 +39,7 @@ $head = @"
padding: 3px;
}
</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
ConvertTo-Html -Head $head -Body $serversHtml | Out-File $reportPath
72 changes: 72 additions & 0 deletions AD-computers-network-html-report.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# 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: #FFFFFF;
font-family: sans-serif;
}
h1 {
color: #1E87F0;
}
h2 {
color: #1E87F0;
}
table {
background-color: #1E87F0;
}
td {
background-color: #FFFFFF;
color: #666666;
padding: 3px;
}
th {
background-color: #1E87F0;
color: #FFFFFF;
text-align: left;
padding: 3px;
}
</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
File renamed without changes.
6 changes: 4 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ Here is a brief description of each script:

AD-computers-html-report.ps1: Produces an html file listing all computers in Active Directory.

AD-computers-network-html-report.ps1: Produces an html file listing the network configuration of all computers in Active Directory.

AD-get-server-status.ps1: Tests to see if all the computers in AD are up and running, and creates two text files listing connected servers and failed servers.

AD-passwords-expiring-csv.ps1: Creates a csv of Active Directory users whose passwords are expiring in the next 7 days.

AD-passwords-expiring-soon-email.ps1: Sends an email to any user whose password expires in the next 7 days
Expand Down Expand Up @@ -53,8 +57,6 @@ file-watcher.ps1: Watches a folder for the creation of files, then runs a script

get-cmdlets-list.ps1: Creates a list of cmdlets.

get-inactive-servers.ps1: Tests to see if all the computers in AD are up and running.

get-module-commands.ps1: Creates a list of cmdlets for the specified module.

git-init.ps1: Creates git repository and pushes code to remote repository
Expand Down

0 comments on commit 4ccce03

Please sign in to comment.