Enhance error handling in Get-CAHostObject and Find-ESC7 scripts#248
Merged
Conversation
…hecking for CAHostDistinguishedName before retrieving AD objects.
Owner
|
DUDE. You're a beast. I'll look at this later tonight. |
Contributor
Author
|
It also produced incorrect results in ESC16 when the CA was unavailable. PS C:\Users\blabla\Documents\WindowsPowerShell\Modules\Locksmith> Invoke-Locksmith -Scans ESC16 -Verbose
_ _____ _______ _ _ _______ _______ _____ _______ _ _
| | | | |____/ |______ | | | | | |_____|
|_____ |_____| |_____ | \_ ______| | | | __|__ | | |
.--. .--. .--.
/.-. '----------. /.-. '----------. /.-. '----------.
\'-' .---'-''-'-' \'-' .--'--''-'-' \'-' .--'--'-''-'
'--' '--' '--'
v<ModuleVersion>
Gathering AD CS Objects from pharmax.local...
WARNING: Unable to resolve pharmax-CAYEY-DC-01V-CA Fully Qualified Domain Name (FQDN)
Get-ADObject : Cannot validate argument on parameter 'Identity'. The argument is null. Provide a valid value for the argument, and then try running the command again.
At C:\Users\blabla\Documents\WindowsPowerShell\Modules\Locksmith\Private\Get-CAHostObject.ps1:47 char:30
+ Get-ADObject $_.CAHostDistinguishedName -Properties * ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-ADObject], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.ActiveDirectory.Management.Commands.GetADObject
Identifying Issuing CAs with szOID_NTDS_CA_SECURITY_EXT disabled (ESC16)...
---------------------------------------------------------------
ESC16 - szOID_NTDS_CA_SECURITY_EXT Extension Disabled
---------------------------------------------------------------
Technique CA Name Risk Issue
--------- ------- ---- -----
ESC16 pharmax-CAYEY-DC-01V-CA Medium **CA Unavailable**
[!] You ran Locksmith in Mode 0 which only provides an high-level overview of issues
identified in the environment. For more details including:
- DistinguishedName of impacted object(s)
- Remediation guidance and/or code
- Revert guidance and/or code (in case remediation breaks something!)
Run Locksmith in Mode 1!
# Module version
Invoke-Locksmith -Mode 1
# Script version
.\Invoke-Locksmith.ps1 -Mode 1
Thank you for using Locksmith <3
PS C:\Users\blabla\Documents\WindowsPowerShell\Modules\Locksmith> |
Owner
|
Do you mind syncing your branch with the |
Contributor
Author
|
Done! |
jakehildreth
approved these changes
May 20, 2025
Owner
jakehildreth
left a comment
There was a problem hiding this comment.
Hmmmm, still not synced, but that's okay. It's only like 3 lines, so i'll do the work. Thank you for your PR!
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I did not modify the Invoke-Locksmith.ps1 file because my editor automatically changes the spacing between 'if' and 'else'. I'm unsure if this is a bug or if the file does not adhere to the specified formatting option.
“powershell.codeFormatting.preset": ‘OTBS’.
Before fix:
After fix: