Skip to content

Commit 168b4bf

Browse files
authored
Change parameters from switch to boolean type
1 parent cab11e1 commit 168b4bf

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

Azure Active Directory/MSADPT/MSADPT_audit_adcs_esc1_esc16.ps1

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,21 @@
7474

7575
param(
7676
[Parameter(Mandatory)]
77+
[ValidateNotNullOrEmpty()]
7778
[string]$OutputBaseDir,
7879

7980
[Parameter(Mandatory)]
80-
[switch]$IncludeUnpublishedTemplates,
81+
[bool]$IncludeUnpublishedTemplates,
8182

8283
[Parameter(Mandatory)]
83-
[switch]$SkipRemoteChecks,
84+
[bool]$SkipRemoteChecks,
8485

8586
[Parameter(Mandatory)]
87+
[ValidateNotNullOrEmpty()]
8688
[string]$DirectoryServer,
8789

8890
[Parameter(Mandatory)]
91+
[ValidateNotNull()]
8992
[PSCredential]$Credential
9093
)
9194

@@ -421,12 +424,21 @@ function Add-ESCFinding {
421424
# ---------------------------------------------------------------------
422425
$adSplat = New-MSADPTAdCommandSplat -Server $DirectoryServer -Credential $Credential
423426

427+
# ---------------------------------------------------------------------
428+
# Pre-flight: AD connectivity check
429+
# ---------------------------------------------------------------------
430+
$rootDSE = Test-MSADPTADConnectivity -Credential $Credential -AdServer $DirectoryServer
431+
if (-not $rootDSE) {
432+
Write-Log -Message "Active Directory connectivity pre-flight failed. Aborting." -Level 'ERROR'
433+
exit 1
434+
}
435+
424436
# ---------------------------------------------------------------------
425437
# Enumerate AD CS / PKI objects
426438
# ---------------------------------------------------------------------
427439
try {
428-
$rootDse = Get-ADRootDSE @adSplat -ErrorAction Stop
429-
$configNc = $rootDse.configurationNamingContext
440+
#$rootDse = Get-ADRootDSE @adSplat -ErrorAction Stop
441+
$configNc = $rootDSE.configurationNamingContext
430442

431443
$templatesBase = "CN=Certificate Templates,CN=Public Key Services,CN=Services,$configNc"
432444
$enrollmentBase = "CN=Enrollment Services,CN=Public Key Services,CN=Services,$configNc"

0 commit comments

Comments
 (0)