Skip to content

Commit

Permalink
Merge pull request #17 from AsBuiltReport/dev
Browse files Browse the repository at this point in the history
v0.2.0 public release
  • Loading branch information
rebelinux authored Jun 27, 2023
2 parents f20c09b + 6c8bdb9 commit 2ea46ad
Show file tree
Hide file tree
Showing 27 changed files with 855 additions and 1,326 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
publish-to-gallery:
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set PSRepository to Trusted for PowerShell Gallery
shell: pwsh
run: |
Expand Down
1 change: 1 addition & 0 deletions AsBuiltReport.Microsoft.DHCP.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"Options": {
"ShowDefinitionInfo": false,
"PSDefaultAuthentication": "Negotiate",
"ServerDiscovery": "Domain",
"Exclude": {
"Domains": [],
"DCs": []
Expand Down
2 changes: 1 addition & 1 deletion AsBuiltReport.Microsoft.DHCP.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'AsBuiltReport.Microsoft.DHCP.psm1'

# Version number of this module.
ModuleVersion = '0.1.1'
ModuleVersion = '0.2.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# :arrows_clockwise: Microsoft DHCP As Built Report Changelog

## [0.2.0] - 2023-06-24

### Added

- Added support for standalone DHCP servers (Non DC)

### Changed

- Added ServerDiscovery option to enable standalone DHCP server reporting.

## [0.1.1] - 2023-05-23

### Added
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,14 @@ The **Report** schema provides configuration of the Microsoft DHCP report inform
### Options
The **Options** schema allows certain options within the report to be toggled on or off.

<!-- ********** Add/Remove the number of InfoLevels as required ********** -->
| Sub-Schema | Setting | Default | Description |
|-----------------|--------------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ShowDefinitionInfo | true/false | false | Toggle to enable/disable Microsoft AD term explanations
| PSDefaultAuthentication | Negotiate/Kerberos | Negotiate | Allow to set the value of the PSRemoting authentication method. For Workgroup authentication Negotiate value is required. |
| ServerDiscovery | Domain/Standalone | Domain | Allow to set the DHCP servers discovery |
| Exclude.Domains | Array List | Empty | Allow to filter on AD Domain FQDN |
| Exclude.DCs | Array List | Empty | Allow to filter on AD Domain Controller Server FQDN. |

### InfoLevel
The **InfoLevel** schema allows configuration of each section of the report at a granular level. The following sections can be set.

Expand Down Expand Up @@ -181,4 +188,4 @@ PS C:\> New-AsBuiltReport -Report Microsoft.DHCP -Target 'admin-dhcp-01v.contoso

- Issues with WinRM when using the IP address instead of the "Fully Qualified Domain Name".
- This project relies heavily on the remote connection function through WinRM. For this reason the use of a Windows 10 client is specifically used as a jumpbox.
- This report document the DHCP server service Forest/Domain wide. If you need to document an standalone DHCP server a better option is to use the [**AsBuiltReport.Microsoft.Windows**](https://github.com/AsBuiltReport/AsBuiltReport.Microsoft.Windows) report.
- This report document the DHCP server service Forest/Domain wide. If you need to document an standalone DHCP server the ServerDiscovery option must be set to Standalone.
1,130 changes: 157 additions & 973 deletions Samples/Sample Microsoft DHCP As Built Report.html

Large diffs are not rendered by default.

Binary file modified Samples/Sample Microsoft DHCP As Built Report.pdf
Binary file not shown.
225 changes: 225 additions & 0 deletions Src/Private/Get-AbrADDHCPDomain.ps1

Large diffs are not rendered by default.

228 changes: 119 additions & 109 deletions Src/Private/Get-AbrADDHCPInfrastructure.ps1

Large diffs are not rendered by default.

212 changes: 212 additions & 0 deletions Src/Private/Get-AbrADDHCPStandAlone.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
function Get-AbrADDHCPStandAlone {
<#
.SYNOPSIS
Used by As Built Report to retrieve Microsoft DHCP information from an StandAlone Server
.DESCRIPTION
.NOTES
Version: 0.2.0
Author: Jonathan Colon
Twitter: @jcolonfzenpr
Github: rebelinux
.EXAMPLE
.LINK
#>
[CmdletBinding()]
param (
[Parameter (
Position = 0,
Mandatory)]
[string]
$Domain
)

begin {
Write-PscriboMessage "Discovering DHCP Server information from $($System.ToString().ToUpper())."
}

process {
try {
if ($DomainDHCPs) {
Section -Style Heading1 "$($System.ToString().ToUpper().Split(".", 2)[0])" {
Paragraph "The following section provides a summary of the Dynamic Host Configuration Protocol."
$script:DHCPinDC = $DomainDHCPs
Get-AbrADDHCPInfrastructure -Domain $Domain.split(".", 2).ToUpper()[0]
Section -Style Heading2 "IPv4 Information" {
Paragraph "The following sections detail the configuration of the ipv4 scopes within domain $($Domain)."
BlankLine
try {
Get-AbrADDHCPv4Statistic -Domain $Domain
}
catch {
Write-PScriboMessage -IsWarning "Error: Retreiving DHCP Server IPv4 Statistics from $($Domain.ToString().ToUpper())."
Write-PScriboMessage -IsWarning "$($_.Exception.Message) (IPv4 DHCP Server Statistics)"
}
try {
Get-AbrADDHCPv4FilterStatus -Domain $Domain
}
catch {
Write-PScriboMessage -IsWarning "Error: Retreiving DHCP Server IPv4 Filter Status from $($Domain.ToString().ToUpper())."
Write-PScriboMessage -IsWarning "$($_.Exception.Message) (IPv4 DHCP Server Filter Status)"
}
foreach ($DHCPServer in $DomainDHCPs){
if (Test-Connection -ComputerName $DHCPServer -Quiet -Count 2) {
$TempCIMSession = New-CIMSession $DHCPServer -Credential $Credential -Authentication $Options.PSDefaultAuthentication -ErrorAction Stop
$DHCPScopes = Get-DhcpServerv4Scope -CimSession $TempCIMSession -ComputerName $DHCPServer | Select-Object -ExpandProperty ScopeId
if ($DHCPScopes) {
Section -Style Heading3 "$($DHCPServer.ToUpper().split(".", 2)[0])" {
try {
Get-AbrADDHCPv4Scope -Domain $Domain -Server $DHCPServer
}
catch {
Write-PScriboMessage -IsWarning "$($_.Exception.Message) (IPv4 DHCP Server Scope information)"
}
if ($InfoLevel.DHCP -ge 2) {
try {
Get-AbrADDHCPv4ScopeServerSetting -Domain $Domain -Server $DHCPServer
if ($DHCPScopes) {
Section -Style Heading4 "Scope Configuration" {
Paragraph "The following sections detail the configuration of the ipv4 per scope configuration."
foreach ($Scope in $DHCPScopes) {
Section -Style Heading5 $Scope {
try {
Get-AbrADDHCPv4PerScopeProperty -Server $DHCPServer -Scope $Scope
}
catch {
Write-PScriboMessage -IsWarning "Error: Retreiving DHCP Server IPv4 Scope Exclusion from $($DHCPServer.split(".", 2)[0])."
Write-PScriboMessage -IsWarning "$($_.Exception.Message) (IPv4 DHCP Server Scope Exclusion)"
}
try {
Get-AbrADDHCPv4PerScopeExclusion -Server $DHCPServer -Scope $Scope
}
catch {
Write-PScriboMessage -IsWarning "Error: Retreiving DHCP Server IPv4 Scope Exclusion from $($DHCPServer.split(".", 2)[0])."
Write-PScriboMessage -IsWarning "$($_.Exception.Message) (IPv4 DHCP Server Scope Exclusion)"
}
try {
Get-AbrADDHCPv4PerScopeReservation -Server $DHCPServer -Scope $Scope
}
catch {
Write-PScriboMessage -IsWarning "Error: Retreiving DHCP Server IPv4 Scope reservation from $($DHCPServer.split(".", 2)[0])."
Write-PScriboMessage -IsWarning "$($_.Exception.Message) (IPv4 DHCP Server Scope reservation)"
}

try {
Get-AbrADDHCPv4PerScopeOption -Server $DHCPServer -Scope $Scope
}
catch {
Write-PScriboMessage -IsWarning "Error: Retreiving DHCP Server IPv4 Scope options from $($DHCPServer.split(".", 2)[0])."
Write-PScriboMessage -IsWarning "$($_.Exception.Message) (IPv4 DHCP Server Scope options)"
}

try {
Get-AbrADDHCPv4PerScopePolicy -Server $DHCPServer -Scope $Scope
}
catch {
Write-PScriboMessage -IsWarning "Error: Retreiving DHCP Server IPv4 Scope options from $($DHCPServer.split(".", 2)[0])."
Write-PScriboMessage -IsWarning "$($_.Exception.Message) (IPv4 DHCP Server Scope options)"
}
}
}
}
}
}
catch {
Write-PScriboMessage -IsWarning "$($_.Exception.Message) (IPv4 DHCP Scope Server Options)"
}
}

if ($TempCIMSession) {
Write-PscriboMessage "Clearing CIM Session $($TempCIMSession.Id)"
Remove-CIMSession -CimSession $TempCIMSession
}
}
}
} else {Write-PScriboMessage -IsWarning "Unable to connect to $($DHCPServer). Removing Server from report"}
}
}
Section -Style Heading2 "IPv6 Information" {
Paragraph "The following section provides a IPv6 configuration summary of the Dynamic Host Configuration Protocol."
BlankLine
try {
Get-AbrADDHCPv6Statistic -Domain $Domain
}
catch {
Write-PScriboMessage -IsWarning "Error: Retreiving DHCP Server IPv6 Statistics from $($Domain.ToString().ToUpper())."
Write-PScriboMessage -IsWarning "$($_.Exception.Message) (IPv6 DHCP Server IPv6 Statistics)"
}
foreach ($DHCPServer in $DomainDHCPs){
if (Test-Connection -ComputerName $DHCPServer -Quiet -Count 2) {
$TempCIMSession = New-CIMSession $DHCPServer -Credential $Credential -Authentication $Options.PSDefaultAuthentication -ErrorAction Stop
$DHCPScopes = Get-DhcpServerv6Scope -CimSession $TempCIMSession -ComputerName $DHCPServer | Select-Object -ExpandProperty Prefix
Write-PScriboMessage "Discovering Dhcp Server IPv6 Scopes from $DHCPServer"
if ($DHCPScopes) {
Section -Style Heading3 "$($DHCPServer.ToUpper().split(".", 2)[0])" {
try {
Get-AbrADDHCPv6Scope -Domain $Domain -Server $DHCPServer
}
catch {
Write-PscriboMessage -IsWarning "$($_.Exception.Message) (IPv6 DHCP Scope Information)"
}
if ($InfoLevel.DHCP -ge 2) {
try {
Get-AbrADDHCPv6ScopeServerSetting -Domain $Domain -Server $DHCPServer
if ($DHCPScopes) {
Section -Style Heading4 "Scope Configuration" {
Paragraph "The following section provides a summary 6 Scope Server Options information."
BlankLine
foreach ($Scope in $DHCPScopes) {
Section -Style Heading5 $Scope {
try {
Get-AbrADDHCPv6PerScopeExclusion -Server $DHCPServer -Scope $Scope
}
catch {
Write-PScriboMessage -IsWarning "Error: Retreiving DHCP Server IPv6 Scope Exclusion from $($DHCPServer.split(".", 2)[0])."
Write-PScriboMessage -IsWarning "$($_.Exception.Message) (IPv6 DHCP Server Scope Exclusion)"
}
try {
Get-AbrADDHCPv6PerScopeReservation -Server $DHCPServer -Scope $Scope
}
catch {
Write-PScriboMessage -IsWarning "Error: Retreiving DHCP Server IPv6 Scope reservation from $($DHCPServer.split(".", 2)[0])."
Write-PScriboMessage -IsWarning "$($_.Exception.Message) (IPv6 DHCP Server Scope reservation)"
}
try {
Get-AbrADDHCPv6PerScopeOption -Server $DHCPServer -Scope $Scope
}
catch {
Write-PScriboMessage -IsWarning "Error: Retreiving DHCP Server IPv6 Scope options from $($DHCPServer.split(".", 2)[0])."
Write-PScriboMessage -IsWarning "$($_.Exception.Message) (IPv6 DHCP Server Scope options)"
}
}
}
}
}
}
catch {
Write-PScriboMessage -IsWarning "$($_.Exception.Message) (IPv6 DHCP Scope Server Options)"
}
}
}
}
} else {Write-PScriboMessage -IsWarning "Unable to connect to $($DHCPServer). Removing Server from report"}
}

if ($TempCIMSession) {
Write-PscriboMessage "Clearing CIM Session $($TempCIMSession.Id)"
Remove-CIMSession -CimSession $TempCIMSession
}
}
}
}
}
catch {
Write-PScriboMessage -IsWarning "$($_.Exception.Message) ($($System.ToString().ToUpper()) Domain DHCP Configuration)"
}
}

end {}

}
Loading

0 comments on commit 2ea46ad

Please sign in to comment.