Skip to content

Commit

Permalink
1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhitsolutions committed Mar 29, 2021
1 parent 6456fc4 commit 38ccd83
Show file tree
Hide file tree
Showing 24 changed files with 555 additions and 49 deletions.
6 changes: 3 additions & 3 deletions ADReportingTools.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
RootModule = 'ADReportingTools.psm1'

# Version number of this module.
ModuleVersion = '1.0.0'
ModuleVersion = '1.1.0'

# Supported PSEditions
CompatiblePSEditions = @("Desktop","Core")
Expand Down Expand Up @@ -88,7 +88,7 @@ FunctionsToExport = 'Show-DomainTree','Get-ADUserAudit','Get-ADSummary','Get-ADF
'Get-ADGroupUser','Get-ADBranch','Get-ADDomainControllerHealth','New-ADDomainReport','Get-ADReportingTools','Get-ADCanonicalUser',
'Get-ADUserCategory','Get-ADGroupReport','Split-DistinguishedName','New-ADChangeReport',
'Get-ADReportingToolsOptions','Set-ADReportingToolsOptions','Get-ADDepartment','Get-ADComputerReport', 'Get-NTDSInfo',
'Get-ADBackupStatus'
'Get-ADBackupStatus','Open-ADReportingToolsHelp'

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
#CmdletsToExport = ''
Expand All @@ -114,7 +114,7 @@ PrivateData = @{
PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
Tags = @("ActiveDirectory")
Tags = @("ActiveDirectory","html","reporting")

# A URL to the license for this module.
LicenseUri = 'https://github.com/jdhitsolutions/ADReportingTools/blob/main/LICENSE.txt'
Expand Down
4 changes: 2 additions & 2 deletions ADReportingTools.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ $newRunspace.ApartmentState = "STA"
$newRunspace.ThreadOptions = "ReuseThread"
[void]$newRunspace.Open()
$Global:ADReportingHash = [hashtable]::Synchronized(@{
Note = "This used by the ADReportingTools module. Do not delete."
Note = "This hashtable is used by the ADReportingTools module. Do not delete."
Departments = @()
DomainControllers = @()
BackupLimit = 3
Expand All @@ -53,7 +53,7 @@ $psCmd.Runspace = $newRunspace

$handle = $psCmd.BeginInvoke()

$ADReportingHash.Add("handle", $handle)
$ADReportingHash.Add("Handle", $handle)

#start a job to clean up the runspace
[void](Start-ThreadJob -ScriptBlock {
Expand Down
Binary file added ADReportingToolsManual.pdf
Binary file not shown.
10 changes: 10 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog for ADReportingTools

## 1.1.0

+ Fix typo in `$ADReportingHash` Note. ([Issue #22](https://github.com/jdhitsolutions/ADReportingTools/issues/22))
+ Added `Open-ADReportingToolsHelp` to launch a PDF with module documentation. ([Issue #2](https://github.com/jdhitsolutions/ADReportingTools/issues/2))
+ Fixed bad parameter in `New-ADChangeReport`. ([Issue #24](https://github.com/jdhitsolutions/ADReportingTools/issues/24))
+ Modified CSS parameter in `New-DomainReport`.
+ Modified `Show-DomainTree` to test for ConsoleHost as a match and not equal to. ([Issue #23](https://github.com/jdhitsolutions/ADReportingTools/issues/23))
+ Updated `README.md`.
+ Help updates.

## 1.0.0

+ First stable release.
Expand Down
13 changes: 13 additions & 0 deletions ModuleCommands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Module Functions

This section contains the same help content you would get from a PowerShell prompt using `Get-Help`. Note that most code examples have been formatted to fit the 80 character page width and sometimes with artificial formatting. Don't assume you can run examples _exactly_ as they are shown. Some of the help examples might also use special or custom characters that might not render properly in the PDF.

If you can't remember what commands are in this module, you can always ask PowerShell.

```powershell
Get-Command -module ADReportingTools
```

Or use the `Get-PSScriptTools` command.

![Get-ADReportingTools](images/get-adreportingtools.png)
200 changes: 200 additions & 0 deletions PrepAdoc.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
#requires -version 7.1

[cmdletbinding(SupportsShouldProcess)]
Param(
[Parameter(Position = 0)]
[ValidateNotNullOrEmpty()]
[ValidateScript({Test-Path $_})]
[string]$Path = ".",
[Parameter(HelpMessage = "The path to a json file with the processing data for the folder.")]
[ValidateNotNullOrEmpty()]
[ValidateScript( {Test-Path $_})]
[string]$DataPath = ".\adoc-data.json"
)

$prog = @{
Activity = "Prepare ADOC files"
Status = "Initializing"
CurrentOperation = ""
PercentComplete = 0
}

Write-Progress @prog

$ModulePath = Convert-Path $Path
$moduleName = Split-Path $modulePath -leaf
Write-Verbose "[$(Get-Date)] Working from $modulePath"

Write-Verbose "[$(Get-Date)] Importing ruby-related functions"
. C:\scripts\rubydocs.ps1

Write-Verbose "[$(Get-Date)] Importing adoc data from json"
<#
{
"Name" : "PSScriptToolsManual",
"Title": "PSScriptTools Manual",
"CodeTheme": "githubcustom",
"CodeThemePath": "c:\\scripts\\githubcustom.rb",
"Theme": "pdf-theme.yml",
"Files": [
{
"Name": "Intro.md",
"Lines": ""
},
{
"Name": "README.md",
"Lines": "1;13..15;33..-1"
},
{
"Name": "ModuleCommands.md",
"Lines": ""
}
]
}#>

$data = Get-Content $DataPath | ConvertFrom-Json

Write-Verbose "[$(Get-Date)] Get the module version"
$ver = (Test-ModuleManifest -Path .\$modulename.psd1).version.tostring()
#(Import-PowerShellDataFile $ModulePath\*.psd1).moduleversion
Write-Verbose "[$(Get-Date)] Found version $ver"

#update pdf-them.yml with the module version
Write-Verbose "[$(Get-Date)] Updating book theme yml file"
New-BookThemeYml -version $ver -title "ADReportingTools Help Manual" -image "images/2PopulatedDomain01.png"

#define a here-string for the main document in Asciidoctor format
$Main = @"
= $($data.title) v$Ver
:allow-uri-read:
:autofit-option:
:data-uri:
:icons: font
:iconset: fa
:linkattrs:
:rouge-style: $($data.codeTheme)
:source-highlighter: rouge
"@

$files = $data.files
$prog.status = "Processing main files"
$i = 0
foreach ($file in $files) {
$i++
$prog.CurrentOperation = $file.name
$prog.percentComplete = ($i/$files.count)*100
Write-Progress @prog
$item = Join-Path -Path $Modulepath -ChildPath $file.name
Write-Verbose "[$(Get-Date)] Converting $item"
Get-Item -path $item |
ConvertTo-Adoc -Codetheme $data.codeTheme

$adoc = $item -replace "md", "adoc"
$c = Get-Content $adoc

Write-Verbose "[$(Get-Date)] Adjustings links and xrefs"
[regex]$lx = "xref:(?<link>\S+)\.adoc\[(?<display>((\w+[\s-]\w+))+)\]"
$matchData = $lx.matches($c)
foreach ($item in $matchData) {
$link = $item.groups.where( {$_.name -eq 'link'}).value
$display = $item.groups.where( {$_.name -eq 'display'}).value

#split off the command name from the link to build the
#correct cross-reference in the PDF
$cmdName = $link.split("/")[-1]
$xlink = "$cmdName-Help"
$xref = "<<{0},{1}>>" -f $xlink, $display
#use the method because the value has regex characters
$c = $c.replace($item.value, $xref)
}

Write-Verbose "[$(Get-Date)] Updating $adoc"
$c | Out-File -FilePath $adoc -Encoding utf8

Write-Verbose "[$(Get-Date)] Adding to Main"
#include line subsets if defined
if ($file.lines) {
$trim = "lines=$($file.lines)"
}
else {
$trim = ""
}
$main += @"
include::$($adoc)[$trim]
"@
}

Write-Verbose "[$(Get-Date)] Creating adoc help files. You may need to press Enter to force the process to continue."

#create the adoc files and then edit them.
$prog.Status = "Converting markdown to adoc files"
$prog.CurrentOperation =
$i = 0
$helpMD = Get-ChildItem $ModulePath\docs\*-*.md

$helpmd | ForEach-Object {
$i++
$prog.CurrentOperation = $_.FullName
$prog.percentComplete = ($i/$helpmd.count)*100
Write-Progress @prog
ConvertTo-Adoc -Fullname $_.fullname -passthru -theme $data.codeTheme | Edit-Adoc
}

$prog.status = "Building main document"
Write-Verbose "[$(Get-Date)] Add include links to the main document"
$adocs = Get-ChildItem $ModulePath\docs\*.adoc -OutVariable ov | Sort-Object -property Name

$i = 0
ForEach ($item in $adocs) {
$i++
$prog.CurrentOperation = $item.name
$prog.percentComplete = ($i/$adocs.count)*100
Write-Progress @prog
Write-Verbose "[$(Get-Date)] Adding $($item.name)"
$main += @"
include::docs\$($item.name)[]
"@
}

#Add Changelog
Write-Verbose "[$(Get-Date)] Adding ChangeLog"
ConvertTo-Adoc -Fullname $PSScriptRoot\ChangeLog.md -passthru -theme $data.codeTheme
$log = Join-Path -Path $Modulepath -ChildPath Changelog.adoc

#convert headings to bold monospace
$content = Get-Content -path $log

[regex]$rxVer = "==\s(?<version>v\d+\.\d+\.\d+)"

$rxver.matches($content) | foreach-Object {
$Find = $_.value
$Replace = "``*$($_.groups[1].value)``*"
Write-Verbose "[$(Get-Date)] Replace '$find' with $Replace"
$content = $content.replace($Find,$Replace)
}

$content | Out-File $log -Encoding utf8
$main += @"
include::$log[]
"@

$out = Join-Path -path $ModulePath -child "$($data.name).adoc"
$prog.status = "Finalizing"
$prog.CurrentOperation = $out
Write-Progress @prog
Write-Verbose "[$(Get-Date)] Saving document to $out"
$main | Out-File -FilePath $out -Encoding utf8

Write-Progress -Activity $prog.Activity -Completed

$msg = "Edit and review the adoc files and then run makepdf.ps1."
Write-Host $msg -ForegroundColor Cyan

Write-Verbose "[$(Get-Date)] Finished."
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ The assumption is that you will run these commands with administrator credential
This module is available in the PowerShell Gallery. Install it with `Install-Module` after you have installed the Active Directory RSAT capability.

```powershell
Install-Module -name ADReportingTools
Install-Module -name ADReportingTools -force
```

Once installed, you can run a command like `Get-ADReportingTools` to see list of commands. Or run `Open-ADReportingToolsHelp` to launch a PDF version of this file, as well as command documentation.

## Design Philosophy

The Active Directory module from Microsoft is not especially difficult to use. It is quite easy to get information from Active Directory.
Expand Down Expand Up @@ -47,6 +49,8 @@ The ADReportingTools focuses primarily on working with Active Directory users, g

### Users

![adusers](images/Users01.png)

#### [Get-ADCanonicalUser](docs/Get-ADCanonicalUser.md)

Often you will find user names in the form domain\username. This command makes it easier to find the Active Directory user account using this value. If the Active Directory Recycle Bin feature is enabled, you can use the `IncludeDeletedObjects` parameter to search for the user account if it can't be found with the initial search.
Expand Down Expand Up @@ -133,6 +137,8 @@ DomainDNS : Research.Globomantics.com

### Groups

![adgroups](images/Collection_DomainGroup01.png)

#### [Get-ADGroupUser](docs/Get-ADGroupUser.md)

The `Get-ADGroupUser` command will display all users of a given Active Directory group. The search is automatically recursive. The default output is a formatted table that will highlight disabled accounts in red. The ANSI color coding will only work in a console session.
Expand All @@ -159,6 +165,8 @@ Distribution groups will be shown in green and member counts of 0 in red. The Ag

### Computers

![adcomputers](images/ComputerAccount01.png)

#### [Get-ADDomainControllerHealth](docs/Get-ADDomainControllerHealth.md)

`Get-ADDomainControllerHealth` is intended to give you a quick summary of the overall health of your Active Directory domain controllers. The concept of "health" is based on the following:
Expand All @@ -182,6 +190,8 @@ You can use additional custom views to format the results.

### Reports

![reports](images/Folder_FolderOpenWithDocumentWriting01.png)

The primary goal for this module is reporting. The intention is to provide easy-to-use commands that will provide at least a snapshot view of information you might want to know.

#### [Get-ADSummary](docs/Get-ADSummary.md)
Expand All @@ -204,7 +214,7 @@ If running in a console host, the date value may be shown in red, if the date is

![Get-ADBackupStatus](images/adbackup-status.png)

The date limit is a user-customizable value in $ADReportingHash.
The date limit is a user-customizable value in `$ADReportingHash`.

```powershell
$ADReportinghash.BackupLimit = 5
Expand Down Expand Up @@ -341,4 +351,4 @@ These are items that I'm dreaming about:

I welcome suggestions, feedback, and comments in the module repository's [Discussion](https://github.com/jdhitsolutions/ADReportingTools/discussions) section.

last updated *2021-03-26 21:01:41Z*
last updated *2021-03-29 15:29:03Z*
21 changes: 21 additions & 0 deletions adoc-data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"Name" : "ADReportingToolsManual",
"Title": "ADReportingTools Help Manual",
"CodeTheme": "github",
"CodeThemePath": "",
"Theme": "pdf-theme.yml",
"Files": [
{
"Name": "Intro.md",
"Lines": ""
},
{
"Name": "README.md",
"Lines": "1;15..-2"
},
{
"Name": "ModuleCommands.md",
"Lines": ""
}
]
}
2 changes: 2 additions & 0 deletions docs/Get-ADReportingTools.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ http://jdhitsolutions.com/blog/essential-powershell-resources/

## RELATED LINKS

[Open-ADReportingToolsHelp](Open-ADReportingToolsHelp.md)

[Get-Module]()

[Get-Command]()
Loading

0 comments on commit 38ccd83

Please sign in to comment.