Skip to content

Commit

Permalink
Merge pull request #170 from rebelinux/dev
Browse files Browse the repository at this point in the history
Initial 0.8.2 changes
  • Loading branch information
rebelinux authored Jun 8, 2024
2 parents a5a81e4 + de834fd commit da94bdc
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 67 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/PSScriptAnalyzerSettings.psd1
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
@{
ExcludeRules = @(
'PSUseBOMForUnicodeEncodedFile',
'PSUseToExportFieldsInManifest',
'PSReviewUnusedParameter',
'PSUseDeclaredVarsMoreThanAssignments',
'PSAvoidGlobalVars',
'PSAvoidUsingEmptyCatchBlock'
'PSUseToExportFieldsInManifest'
)
Rules = @{
PSAvoidExclaimOperator = @{
Enable = $true
}
AvoidUsingDoubleQuotesForConstantString = @{
Enable = $true
}
UseCorrectCasing = @{
Enable = $true
}
}
}
2 changes: 1 addition & 1 deletion AsBuiltReport.Microsoft.AD.Style.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ if ($ReportConfig.Report.ShowHeaderFooter) {
}

# Set position of report titles and information based on page orientation
if (!($ReportConfig.Report.ShowCoverPageImage)) {
if (-Not ($ReportConfig.Report.ShowCoverPageImage)) {
$LineCount = 5
}
if ($Orientation -eq 'Portrait') {
Expand Down
2 changes: 1 addition & 1 deletion AsBuiltReport.Microsoft.AD.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'AsBuiltReport.Microsoft.AD.psm1'

# Version number of this module.
ModuleVersion = '0.8.1'
ModuleVersion = '0.8.2'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
11 changes: 6 additions & 5 deletions Src/Private/Get-AbrADDCRoleFeature.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function Get-AbrADDCRoleFeature {
.DESCRIPTION
.NOTES
Version: 0.8.1
Version: 0.8.2
Author: Jonathan Colon
Twitter: @jcolonfzenpr
Github: rebelinux
Expand All @@ -29,12 +29,13 @@ function Get-AbrADDCRoleFeature {

process {
try {
$DCPssSession = New-PSSession $DC -Credential $Credential -Authentication $Options.PSDefaultAuthentication -Name 'ADDCRoleFeature'
if ($DCPssSession) {
if ($DCPssSession = New-PSSession $DC -Credential $Credential -Authentication $Options.PSDefaultAuthentication -Name 'ADDCRoleFeature') {
$Features = Invoke-Command -Session $DCPssSession -ScriptBlock { Get-WindowsFeature | Where-Object { $_.installed -eq "True" -and $_.FeatureType -eq 'Role' } }
Remove-PSSession -Session $DCPssSession
}
if ($Features) {
Section -ExcludeFromTOC -Style NOTOCHeading5 $($DC.ToString().ToUpper().Split(".")[0]) {
$OutObj = @()
$Features = Invoke-Command -Session $DCPssSession -ScriptBlock { Get-WindowsFeature | Where-Object { $_.installed -eq "True" -and $_.FeatureType -eq 'Role' } }
Remove-PSSession -Session $DCPssSession
foreach ($Feature in $Features) {
try {
$inObj = [ordered] @{
Expand Down
6 changes: 3 additions & 3 deletions Src/Private/Get-AbrADDomainController.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function Get-AbrADDomainController {
.DESCRIPTION
.NOTES
Version: 0.8.1
Version: 0.8.2
Author: Jonathan Colon
Twitter: @jcolonfzenpr
Github: rebelinux
Expand All @@ -32,8 +32,8 @@ function Get-AbrADDomainController {
try {
$OutObj = @()
$inObj = [ordered] @{
'Domain Controller' = $DomainController.Count
'Global Catalog' = $GC.Count
'Domain Controller' = ($DomainController | Measure-Object).Count
'Global Catalog' = ($GC | Measure-Object).Count
}
$OutObj += [pscustomobject]$inobj

Expand Down
12 changes: 6 additions & 6 deletions Src/Private/Get-AbrADDomainObject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function Get-AbrADDomainObject {
.DESCRIPTION
.NOTES
Version: 0.8.1
Version: 0.8.2
Author: Jonathan Colon
Twitter: @jcolonfzenpr
Github: rebelinux
Expand Down Expand Up @@ -524,8 +524,8 @@ function Get-AbrADDomainObject {
try {
$OutObj = @()
$inObj = [ordered] @{
'Computers' = $Computers.Count
'Servers' = $Servers.Count
'Computers' = ($Computers | Measure-Object).Count
'Servers' = ($Servers | Measure-Object).Count
}
$OutObj += [pscustomobject]$inobj

Expand Down Expand Up @@ -692,9 +692,9 @@ function Get-AbrADDomainObject {
'DNS HostName' = ConvertTo-EmptyToFiller $Computer.DNSHostName
'Operating System' = ConvertTo-EmptyToFiller $Computer.operatingSystem
'Status' = Switch ($Computer.Enabled) {
'True' {'Enabled'}
'False' {'Disabled'}
default {'Unknown'}
'True' { 'Enabled' }
'False' { 'Disabled' }
default { 'Unknown' }
}
}
$OutObj += [pscustomobject]$inobj
Expand Down
4 changes: 2 additions & 2 deletions Src/Private/Get-AbrADForest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function Get-AbrADForest {
.DESCRIPTION
.NOTES
Version: 0.8.1
Version: 0.8.2
Author: Jonathan Colon
Twitter: @jcolonfzenpr
Github: rebelinux
Expand Down Expand Up @@ -133,7 +133,7 @@ function Get-AbrADForest {
Paragraph 'In cryptography, a certificate authority or certification authority (CA) is an entity that issues digital certificates. A digital certificate certifies the ownership of a public key by the named subject of the certificate. This allows others (relying parties) to rely upon signatures or on assertions made about the private key that corresponds to the certified public key. A CA acts as a trusted third party trusted both by the subject (owner) of the certificate and by the party relying upon the certificate. The format of these certificates is specified by the X.509 or EMV standard.'
BlankLine
}
if (!$Options.ShowDefinitionInfo) {
if (-Not $Options.ShowDefinitionInfo) {
Paragraph "The following section provides a summary of the Active Directory PKI Infrastructure Information."
BlankLine
}
Expand Down
50 changes: 26 additions & 24 deletions Src/Private/Get-AbrADInfrastructureService.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function Get-AbrADInfrastructureService {
.DESCRIPTION
.NOTES
Version: 0.8.1
Version: 0.8.2
Author: Jonathan Colon
Twitter: @jcolonfzenpr
Github: rebelinux
Expand All @@ -30,41 +30,43 @@ function Get-AbrADInfrastructureService {
process {
try {
$DCPssSession = New-PSSession $DC -Credential $Credential -Authentication $Options.PSDefaultAuthentication -Name 'DomainControllerInfrastructureServices'
$Available = Invoke-Command -Session $DCPssSession -ScriptBlock { Get-Service "W32Time" | Select-Object DisplayName, Name, Status }
if ($Available) {
Section -ExcludeFromTOC -Style NOTOCHeading5 $($DC.ToString().ToUpper().Split(".")[0]) {
$OutObj = @()
if ($DC) {
$Services = @('CertSvc', 'DHCPServer', 'DNS', 'DFS Replication', 'Intersite Messaging', 'Kerberos Key Distribution Center', 'NetLogon', 'Active Directory Domain Services', 'W32Time', 'ADWS', 'RPCSS', 'EVENTSYSTEM', 'DNSCACHE', 'SAMSS', 'WORKSTATION', 'Spooler')
foreach ($Service in $Services) {
try {
$Status = Invoke-Command -Session $DCPssSession -ScriptBlock { Get-Service $using:Service -ErrorAction SilentlyContinue | Select-Object DisplayName, Name, Status }
if ($Status) {
$inObj = [ordered] @{
'Display Name' = $Status.DisplayName
'Short Name' = $Status.Name
'Status' = $Status.Status
}
$OutObj += [pscustomobject]$inobj
}
} catch {
Write-PScriboMessage -IsWarning "$($_.Exception.Message) (Domain Controller Infrastructure Services Item)"
if ($DCPssSession -and ($Available = Invoke-Command -Session $DCPssSession -ScriptBlock { Get-Service "W32Time" | Select-Object DisplayName, Name, Status })) {
$OutObj = @()
$Services = @('CertSvc', 'DHCPServer', 'DNS', 'DFS Replication', 'Intersite Messaging', 'Kerberos Key Distribution Center', 'NetLogon', 'Active Directory Domain Services', 'W32Time', 'ADWS', 'RPCSS', 'EVENTSYSTEM', 'DNSCACHE', 'SAMSS', 'WORKSTATION', 'Spooler')
foreach ($Service in $Services) {
try {
$Status = Invoke-Command -Session $DCPssSession -ScriptBlock { Get-Service $using:Service -ErrorAction SilentlyContinue | Select-Object DisplayName, Name, Status }
if ($Status) {
$inObj = [ordered] @{
'Display Name' = $Status.DisplayName
'Short Name' = $Status.Name
'Status' = $Status.Status
}
$OutObj += [pscustomobject]$inobj
}
} catch {
Write-PScriboMessage -IsWarning "$($_.Exception.Message) (Domain Controller Infrastructure Services Item)"
}
}

if ($HealthCheck.DomainController.Services) {
$OutObj | Where-Object { $_.'Status' -notlike 'Running' -and $_.'Short Name' -notlike 'Spooler' } | Set-Style -Style Warning -Property 'Status'
$OutObj | Where-Object { $_.'Short Name' -eq 'Spooler' } | Set-Style -Style Critical
}
if ($HealthCheck.DomainController.Services) {
$OutObj | Where-Object { $_.'Status' -notlike 'Running' -and $_.'Short Name' -notlike 'Spooler' } | Set-Style -Style Warning -Property 'Status'
$OutObj | Where-Object { $_.'Short Name' -eq 'Spooler' } | Set-Style -Style Critical
}

if ($OutObj) {
Section -ExcludeFromTOC -Style NOTOCHeading5 $($DC.ToString().ToUpper().Split(".")[0]) {

$TableParams = @{
Name = "Infrastructure Services Status - $($DC.ToString().ToUpper().Split(".")[0])"
List = $false
ColumnWidths = 40, 40, 20
}

if ($Report.ShowTableCaptions) {
$TableParams['Caption'] = "- $($TableParams.Name)"
}

$OutObj | Sort-Object -Property 'Display Name' | Table @TableParams
if ($HealthCheck.DomainController.Services -and ($OutObj | Where-Object { $_.'Short Name' -eq 'Spooler' -and $_.'Status' -like 'Running' })) {
Paragraph "Health Check:" -Bold -Underline
Expand Down
4 changes: 2 additions & 2 deletions Src/Private/Get-AbrADSite.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function Get-AbrADSite {
.DESCRIPTION
.NOTES
Version: 0.8.1
Version: 0.8.2
Author: Jonathan Colon
Twitter: @jcolonfzenpr
Github: rebelinux
Expand Down Expand Up @@ -81,7 +81,7 @@ function Get-AbrADSite {
}
$OutObj | Sort-Object -Property 'Site Name' | Table @TableParams
if ($HealthCheck.Site.BestPractice -and (($OutObj | Where-Object { $_.'Subnets' -eq '--' }) -or ($OutObj | Where-Object { $_.'Description' -eq '--' }))) {
Paragraph "Health Check:" -Bold -Underline
Paragraph 'Health Check:' -Bold -Underline
BlankLine
if ($OutObj | Where-Object { $_.'Subnets' -eq 'No subnet assigned' }) {
Paragraph {
Expand Down
6 changes: 3 additions & 3 deletions Src/Private/Get-AbrADTrust.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function Get-AbrADTrust {
.DESCRIPTION
.NOTES
Version: 0.8.1
Version: 0.8.2
Author: Jonathan Colon
Twitter: @jcolonfzenpr
Github: rebelinux
Expand Down Expand Up @@ -52,14 +52,14 @@ function Get-AbrADTrust {
16 { "Cross-Organizational Trust (Selective Authentication)" }
32 { "Intra-Forest Trust (trust within the forest)" }
64 { "Inter-Forest Trust (trust with another forest)" }
default {$Trust.TrustAttributes}
default { $Trust.TrustAttributes }
}
'Trust Direction' = Switch ($Trust.TrustDirection) {
0 { "Disabled (The trust relationship exists but has been disabled)" }
1 { "Inbound (TrustING domain)" }
2 { "Outbound (TrustED domain)" }
3 { "Bidirectional (two-way trust)" }
default {$Trust.TrustDirection}
default { $Trust.TrustDirection }
}
'IntraForest' = ConvertTo-TextYN $Trust.IntraForest
'Selective Authentication' = ConvertTo-TextYN $Trust.SelectiveAuthentication
Expand Down
4 changes: 2 additions & 2 deletions Src/Private/Get-AbrDNSSection.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function Get-AbrDNSSection {
.DESCRIPTION
.NOTES
Version: 0.8.1
Version: 0.8.2
Author: Jonathan Colon
Twitter: @jcolonfzenpr
Github: rebelinux
Expand All @@ -29,7 +29,7 @@ function Get-AbrDNSSection {
Paragraph "The Domain Name System (DNS) is a hierarchical and decentralized naming system for computers, services, or other resources connected to the Internet or a private network. It associates various information with domain names assigned to each of the participating entities. Most prominently, it translates more readily memorized domain names to the numerical IP addresses needed for locating and identifying computer services and devices with the underlying network protocols."
BlankLine
}
if (!$Options.ShowDefinitionInfo) {
if (-Not $Options.ShowDefinitionInfo) {
Paragraph "The following section provides a summary of the Active Directory DNS Infrastructure Information."
BlankLine
}
Expand Down
21 changes: 12 additions & 9 deletions Src/Private/Get-AbrDomainSection.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function Get-AbrDomainSection {
Paragraph "An Active Directory domain is a collection of objects within a Microsoft Active Directory network. An object can be a single user or a group or it can be a hardware component, such as a computer or printer.Each domain holds a database containing object identity information. Active Directory domains can be identified using a DNS name, which can be the same as an organization's public domain name, a sub-domain or an alternate version (which may end in .local)."
BlankLine
}
if (!$Options.ShowDefinitionInfo) {
if (-Not $Options.ShowDefinitionInfo) {
Paragraph "The following section provides a summary of the Active Directory Domain Information."
BlankLine
}
Expand Down Expand Up @@ -69,7 +69,7 @@ function Get-AbrDomainSection {
Paragraph "A domain controller (DC) is a server computer that responds to security authentication requests within a computer network domain. It is a network server that is responsible for allowing host access to domain resources. It authenticates users, stores user account information and enforces security policy for a domain."
BlankLine
}
if (!$Options.ShowDefinitionInfo) {
if (-Not $Options.ShowDefinitionInfo) {
if ($InfoLevel.Domain -ge 2) {
Paragraph "The following section provides detailed information about Active Directory domain controllers."
BlankLine
Expand All @@ -89,7 +89,7 @@ function Get-AbrDomainSection {
Paragraph "The following section provides a summary of installed role & features on $Domain DCs."
foreach ($DC in $DCs) {
$DCStatus = Test-Connection -ComputerName $DC -Quiet -Count 2
if ($DCStatus -eq $false) {
if (-Not $DCStatus) {
Write-PScriboMessage -IsWarning "Unable to connect to $DC. Removing it from the $Domain report"
}
if ($DCStatus) {
Expand All @@ -115,12 +115,15 @@ function Get-AbrDomainSection {
}
}
try {
Section -Style Heading4 "Infrastructure Services" {
Paragraph "The following section provides a summary of the Domain Controller Infrastructure services status."
foreach ($DC in $DCs) {
if (Test-Connection -ComputerName $DC -Quiet -Count 2) {
Get-AbrADInfrastructureService -DC $DC
}
$ADInfraServices = foreach ($DC in $DCs) {
if (Test-Connection -ComputerName $DC -Quiet -Count 2) {
Get-AbrADInfrastructureService -DC $DC
}
}
if ($ADInfraServices) {
Section -Style Heading4 "Infrastructure Services" {
Paragraph "The following section provides a summary of the Domain Controller Infrastructure services status."
$ADInfraServices
}
}
} catch {
Expand Down
Loading

0 comments on commit da94bdc

Please sign in to comment.