r/usefulscripts • u/MadBoyEvo • Sep 08 '19
[PowerShell] Testimo - PowerShell module for Active Directory Health Checks
Some time ago I've decided I'm a bit too lazy for manual verification of my Active Directory when it comes to doing Health Checks. I've caught myself a few times where I've configured 4 out of 5 Domain Controllers thinking everything is running great. While there are "pay" tools on the market I've usually no budget. And when you search for Active Directory Health Checks you can find a lot of blog posts covering Active Directory Health Checks. However, everyone treats every health check separately. If you want to test 20 different things you're gonna spend next 8 hours doing just that. And when you're done you should start all over the next day because something may have changed.
I wrote a PowerShell module called Testimo which bundles a lot of Active Directory checks and make it easy to expand on. It targets Forest/Domain and all it's Domain Controllers. It has reporting built-in. It's able to work ad-hoc to asses someone else directory and find what's misconfigured, but also has advanced configured which can test your AD against given specific settings.
Following "health" checks are added for now. I do intend to add more as I go. It's quite easy to add more sources/tests so if you wanna help out - please do. Of course, I may have done a few misconfigurations, some errors while putting it all together - so make sure to let me know via GitHub issues if you think some settings are incorrect and should be changed.
Forest Backup – Verify last backup time should be less than X days
Forest Replication – Verify each DC in replication site can reach other replication members
Forest Optional Features – Verify Optional Feature Recycle Bin should be Enabled
Forest Optional Features- Verify Optional Feature Privileged Access Management Feature should be Enabled
Forest Optional Features – Verify Optional Feature Laps should be enabled Configured
Forest Sites Verification Verify each site has at least one subnet configured
Forest Sites Verification Verify each site has at least one domain controller configured
Forest Site Links – Verify each site link is automatic
Forest Site Links – Verify each site link uses notifications
Forest Site Links- Verify each site link does not use notifications
Forest Roles Verify each FSMO holder is reachable
Forest Orphaned/Empty Admins – Verify there are no Orphaned Admins (users/groups/computers)
Forest Tombstone Lifetime – Verify Tombstone lifetime is greater or equal 180 days
Domain Roles Verify each FSMO holder is reachable
Domain Password Complexity Requirements – Verify Password Complexity Policy should be Enabled
Domain Password Complexity Requirements – Verify Password Length should be greater than X
Domain Password Complexity Requirements – Verify Password Threshold should be greater than X
Domain Password Complexity Requirements – Verify Password Lockout Duration should be greater than X minutes
Domain Password Complexity Requirements – Verify Password Lockout Observation Window should be greater than X minutes
Domain Password Complexity Requirements – Verify Password Minimum Age should be greater than X
Domain Password Complexity Requirements – Verify Password History Count should be greater than X
Domain Password Complexity Requirements – Verify Password Reversible Encryption should be Disabled
Domain Trust Availability – Verify each Trust status is OK
Domain Trust Unconstrained TGTDelegation – Verify each Trust TGTDelegation is set to True
Domain Kerberos Account Age – Verify Kerberos Last Password Change Should be less than 180 days
Domain Groups: Account Operators – Verify Group is empty
Domain Groups: Schema Admins – Verify Group is empty
Domain User: Administrator – Verify Last Password Change should be less than 360 days or account disabled
Domain DNS Forwarders – Verify DNS Forwarders are identical on all DNS nodes
Domain DNS Scavenging Primary DNS Server – Verify DNS Scavenging is set to X days
Domain DNS Scavenging Primary DNS Server – Verify DNS Scavenging State is set to True
Domain DNS Scavenging Primary DNS Server – Verify DNS Scavenging Time is less than X days
Domain DNS Zone Aging – Verify DNS Zone Aging is set
Domain Well known folder – UsersContainer Verify folder is not at it's defaults.
Domain Well known folder – ComputersContainer Verify folder is not at it's defaults.
Domain Well known folder – DomainControllersContainer Verify folder is at it's defaults.
Domain Well known folder – DeletedObjectsContainer Verify folder is at it's defaults.
Domain Well known folder – SystemsContainer Verify folder is at it's defaults.
Domain Well known folder – LostAndFoundContainer Verify folder is at it's defaults.
Domain Well known folder – QuotasContainer Verify folder is at it's defaults.
Domain Well known folder – ForeignSecurityPrincipalsContainer Verify folder is at it's defaults.
Domain Orphaned Foreign Security Principals – Verify there are no orphaned FSP objects.
Domain Orphaned/Empty Organizational Units – Verify there are no orphaned Organizational Units
Domain Group Policy Missing Permissions – Verify Authenticated Users/Domain Computers are on each and every Group Policy
Domain DFSR Sysvol – Verify SYSVOL is DFSR
Domain Controller Information – Is Enabled
Domain Controller Information – Is Global Catalog
Domain Controller Service Status – Verify all Services are running
Domain Controller Service Status – Verify all Services are set to automatic startup
Domain Controller Service Status (Print Spooler) – Verify Print Spooler Service is set to disabled
Domain Controller Service Status (Print Spooler) – Verify Print Spooler Service is stopped
Domain Controller Ping Connectivity – Verify DC is reachable
Domain Controller Ports – Verify Following ports 53, 88, 135, 139, 389, 445, 464, 636, 3268, 3269, 9389 are open
Domain Controller RDP Ports – Verify Following ports 3389 (RDP) is open
Domain Controller RDP Security – Verify NLA is enabled
Domain Controller LDAP Connectivity – Verify all LDAP Ports are open
Domain Controller LDAP Connectivity – Verify all LDAP SSL Ports are open
Domain Controller Windows Firewall – Verify windows firewall is enabled for all network cards
Domain Controller Windows Remote Management – Verify Windows Remote Management identification requests are managed
Domain Controller Resolves internal DNS queries – Verify DNS on DC resolves Internal DNS
Domain Controller Resolves external DNS queries – Verify DNS on DC resolves External DNS
Domain Controller Name servers for primary domain zone Verify DNS Name servers for primary zone are identical
Domain Controller Responds to PowerShell Queries Verify DC responds to PowerShell queries
Domain Controller TimeSettings – Verify PDC should sync time to external source
Domain Controller TimeSettings – Verify Non-PDC should sync time to PDC emulator
Domain Controller TimeSettings – Verify Virtualized DCs should sync to hypervisor during boot time only
Domain Controller Time Synchronization Internal – Verify Time Synchronization Difference to PDC less than X seconds
Domain Controller Time Synchronization External – Verify Time Synchronization Difference to pool.ntp.org less than X seconds
Domain Controller Disk Free – Verify OS partition Free space is at least X %
Domain Controller Disk Free – Verify NTDS partition Free space is at least X %
Domain Controller Operating System – Verify Windows Operating system is Windows 2012 or higher
Domain Controller Windows Updates – Verify Last patch was installed less than 60 days ago
Domain Controller SMB Protocols – Verify SMB v1 protocol is disabled
Domain Controller SMB Protocols – Verify SMB v2 protocol is enabled
Domain Controller SMB Shares – Verify default SMB shares NETLOGON/SYSVOL are visible
Domain Controller DFSR AutoRecovery – Verify DFSR AutoRecovery is enabled
Domain Controller Windows Roles and Features – Verify Windows Features for AD/DNS/File Services are enabled
I welcome all good/bad feedback.
- blog post with description: https://evotec.xyz/what-do-we-say-to-health-checking-active-directory/
- sources: https://github.com/EvotecIT/Testimo
It's an alpha product - but I've tested it on 3-4 AD's I have and so far it works ok. I've probably missed some things so if you find some bugs please let me know.
1
u/VulturE Sep 08 '19 edited Sep 08 '19
Plenty of good stuff I was able to find and changes I will be recommending. Definitely would be nice to see the 2008 R2 support added so people can use it to get their site correct before upgrading to something newer. We just moved to DFSR from FRS and I was delighted to find that it was a blocking item before we could move the old DCs to 2019.
Notes:
2. Best practice is still to have your PDC FSMO server detected by GPO and dynamically adjust the time settings to point to a different source (either internal time hardware or an external time server). https://blogs.technet.microsoft.com/askds/2008/11/13/configuring-an-authoritative-time-server-with-group-policy-using-wmi-filtering/. When I called MS they said this is still what they recommend - I didn't like that we were relying on WMI Filtering in a GPO, but it does work correctly when tested. 3. Not sure if it was because I was running it from my laptop instead of a DC, but "Resolve-DnsName" was not recognized as a function for the 2008 R2 DCs - or atleast thats the error that they threw. May be that they just need Powershell upgraded? I coulda sworn we already upgraded them though... 4. Sites that exist without DCs should only fail if they're apart of any of any site links and/or have subnets assigned to them. We aren't using the default zone and have no subnets assigned to it, but MS advises at worst to not delete it, and at best to rename and reuse it for your primary site. We haven't done option 2, but AFAIK the KDC detects an empty site as one with no subnets or DCs assigned to it. 5. Last DNS Scavenging Time - expected was Less Than 9/1/19. Actual was 9/4/19. That failed. Unless I'm misreading it, it should have been a Pass?
1
u/MadBoyEvo Sep 08 '19
Resolve-DnsName seems to be part of 2012+. Installing PS5 doesn't change much, unfortunately (I tried). Thanks for the notes. I would be happy if you can propose those as issues on GitHub so one could go one by one.
Some tests are there with "my defaults" but anyone can go and disable some tests or have different settings for them.
1
u/SolidKnight Oct 01 '19
I really like this tool and look forward to your next release. I also really like the links to resources in the source.
I do have a question though. Why is the PDC time test expecting AllSync? I thought the best practice was for it to be NTP.
I also bumped into this
In some scenarios involving guest domain controllers, Hyper-V TimeSync samples can disrupt domain time synchronization. This should no longer be an issue for Server 2016 guests running on Server 2016 Hyper-V hosts.
Seems drift shouldn't occur because of Hyper-V Time Synchronization services anymore as long as you're 2016+ on 2016+.
1
u/MadBoyEvo Oct 02 '19
I guess I need to review that rule. If you can open issues on Testimo so this can be tracked that would be cool.
1
u/SolidKnight Oct 02 '19
Cool. Will do. I just didn't want to open an issue in case I was just out of the loop on something.
3
u/hayfever76 Sep 08 '19
OP, this is great. I found some really interesting things to harden on my DC's that i had not even thought of before. Woot, thanks again